How can I access / call class member function from main?

Joined
Mar 28, 2009
Messages
3
Reaction score
0
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

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;
}
BTW errors are always different, from "expected primary expression before "database" to some "expected initialization before '.' token"

please advise :bored:
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top