error passing object type to a function
The problem I have is how to pass an Object element trough a function that exist in an all other file.
Here is a part of the code I am working on
Simulator.cpp
1 2 3 4 5 6
|
Store::Store(int num):num(num)
{
for(int i=0; i<num; i++)
lineQueue.push_back(queue<Client>());
}
|
store.cpp
1 2 3 4 5 6 7 8 9 10 11 12
|
Store::addClient(const Client& client){
string fname, lname;
cout<<"Client First Name : ";
getline(cin,fname);
cout<<"Client Last Name : ";
getline(cin,lname);
Client newClient(fname,lname);
lineQueue.push_back(Client);
}
...More functions..
|
Using this code, I get errore saying :
1 2 3
|
error #1:
Simulator.cpp:34:27: error: 'Client' does not refer to a value
myStore.addClient(Client);
|
and error#2:
1 2 3 4
|
Store.cpp:23:26: error: 'Client' does not refer to a value
lineQueue.push_back(Client);
^
./Client.h:16:7: note: declared here
|
I may be too tired to see the mistake I am making
The return type and statement of Store::addClient() are not specified in store.cpp
Last edited on
Look at this line (line 10 in your second code snippet):
lineQueue.push_back(Client);
Client isn't an object - it's a type. What you've written is equivalent to:
lineQueue.push_back(int);
if lineQueue were a collection of ints.
Topic archived. No new replies allowed.