With namespace std, if you are just using cout & cin you can have
1 2
|
using std::cout
using std::cin
|
at the front of your file.
Is this all of your code? I don't see a constructor for Car object.
In Main:
1 2
|
Car one();
Car.tostring;
|
The first staement create a new object of type Car. The () means it's calling the the default contructor with no arguements. You don't have a default contructor (unless you haven't shown it to us). So the program doesn't actualy do anything. Usually we create new objects with the new operator. This will return a pointer, which you use to access it's members.
If you don't do this, then you access public members via the object. So the second statement above should be :
Constructors are used to initialise variables. A good way of doing things is to have a constructor call an init fuction, then have other functions that process or calculate the info. This brings me to the names of your functions - they are misleading. To me and a lot of other people ToInt implies conversion to an Integer. A better choice might be SetIntValues and SetStringValues, both of which are called from the Init function in the constructor.
Usually we have public get & set functions to work with private member variables.
I suggest you read up about constructors, overloading, private, public, protected variables.
Hope this helps, let us know how you get on.