"error: request for member 'firstname' in 'object2', which is of non-class type 'employee()'"
I have searched other forums and it appears the problem is when initializing object2. People have said to use employee object2;
rather than,
employee object2();
but that brings the error,
"error: no matching function for call to 'employee::employee()'"
So I am unsure on what to do now.
Here is the bulk of my code. Left the function definitions out.
I am trying to initialize object2 by using the modifiers.
We need to provide a constructor that takes no arguments at all, which would look like the one that I give in my other post on this topic.
1 2 3 4 5
employe::employee()
{
//do whatever you want with the values
string = ""; //one example - just an empty string
}
If you just do employee object2; with the constructor you are using, your program doesn't know how to set the values for firstname, designation, or salary.
However now I am running into the problem of having the user input the details of another object. I am trying to take the input using the >> operator.
So I declare object 3 like,
employee object3;
Then could I do something like
1 2
string name;
object3.firstname >> name >> endl;
Or would I need to create another void function that takes in user input and sets it to each variable found within the object? Or perhaps it be best to modify this?
Okay yeah that makes sense. the prompt I was given only included the ">>" and did not mention cin >> so I figured a separate function would be needed. But that works, so thanks a bunch the help and for the quick reply!