Hello everyone. I am new to classes, and I am kinda tuck on this homework assignment.
I want to access class member function from main.
And I don't know the way to write it
What should I change in order for this piece to work. :hmm2:
PROBLEM IN LINE 33
BTW errors are always different, from "expected primary expression before "database" to some "expected initialization before '.' token"
please advise :bored:
I want to access class member function from main.
And I don't know the way to write it
What should I change in order for this piece to work. :hmm2:
PROBLEM IN LINE 33
Code:
#include <iostream>
using namespace std;
const int SIZE=1000;
class gameItem{
private:
int price;
public:
void setPrice (int);
};
void gameItem::setPrice (int x){
price=x;
}
class DataBase{
private:
gameItem database[SIZE];
public:
void add_game(gameItem database);
};
void DataBase::add_game(gameItem database){
cout<<"Hello Database!"<<endl;
//Here I want to add game to the database
};
int main(){
DataBase db();
db().add_game(gameItem database);//[COLOR="Red"]<-- PROBLEM IN THIS LINE (line33)[/COLOR]
return 0;
}
please advise :bored:
Last edited: