Supposing I have a class Dog with attributes age and color. I also have a function print(string) which invokes the accessor functions for the dog attributes. Now when the user enters the name of a Dog object at the command line I would like to call the print function to print these attributes to the screen.
string name;
cout << "Enter the name of a dog";
cin << name;
cout << print(name);
Now, how do I cast the string data type entered by the user into a Dog object so that I can invoke the class functions directly?
Or am I going about it the wrong way?
Please help, this is not homework, I am just trying to learn!