I have a object called Shopper that i want to pass through an other function, but i didn't find how todo it.
I called the function HardwareStore::inputShopper() to input the name of the new shopper, and I am trying to pass it to an other function from the same cpp file. just to check if it's working.
The Error messages i get is this one:
MainProgram.cppCode:HardwareStore.cpp:24:16: error: redefinition of 'newShopper' with a different type : 'HardwareStore' vs 'Shopper::Shopper' HardwareStore(newShopper); HardwareStore.cpp:23:19: error: previous definition is here Shopper::Shopper newShopper(name,lname); 1error generated.
HardwareStore.cppCode:HardwareStore hws(10); hws.inputShopper();
Shopper.cppCode:HardwareStore::HardwareStore(int numRegisters):numRegisters(numRegisters) { for(int i=0; i<numRegisters; i++) registerQueue.push_back(queue<Shopper>()); cout<<"This Worked"<<endl; } void HardwareStore::inputShopper(){ string fname, lname; cout<<"First name : "; getline(cin, fname); cout<<"Last Name : "; getline(cin, lname); Shopper::Shopper newShopper(fname,lname); HardwareStore(newShopper); } void HardwareStore::addShopperToLine(const Shopper& shopper){ cout<<"if it displays, it means it s Working"; }
Code:Shopper::Shopper(const string& firstName, const string& lastName):firstName(firstName),lastName(lastName){ ShoppingCart newChoppingList; } string Shopper::getFname(){ return firstName; } string Shopper::getLname(){ return lastName; }




Reply With Quote
