Hi,
I am declaring an object from within a function, and am trying to pass the object back into main.
When looking up what datatype to use to hold the object,(where you could use 'void' in a function declaration), all I find are the fundamental datatypes such as int and bool.
Hear is the part of the function:
Code:switch (choice) { case 1: { cout << "Before creating an object of type car" << endl; cars temp; //construct an object called 'temp' of type 'cars' cout << "Enter the MPG" << endl; cin >> temp.MPG; cout << "After creating an object of type car" << endl; return temp; } }
I want to return the object 'temp' of class 'cars' back to main, but I'm finding the fundamental datatypes don't work.
Thanks for any help!



LinkBack URL
About LinkBacks


