1> User.cpp
1>g:\webasvisor 3.0\webasvisor 3.0\user.cpp(5): error C2228: left of '.name' must have class/struct/union |
In
User.cpp on
line 3 User::User, the scope resolution operator places you inside the User class scope and so from there on to the end of the function class members are accessed directly without the scope resolution operator. Change
line 5:
User::User.name = "";
to
name = "";
What about the compiler's error message that
left of '.name' must have class/struct/union |
? There actually is implicitly a class to the left of .name, the
this pointer which points to the object being instantiated. That is, writing:
name = "";
is the equivalent of
this->name = "";
which in turn is equivalent to
( *this ).name;
. Still, you shouldn't use the this pointer in this case since it is already there implicitly.
The other errors appear to be similar.
Also, in
User.h in
lines 19 and
20 the first User in each line is redundant because you are already within the User class scope. Change
lines 19 and
20 to:
1 2
|
User();
User(std::string name, std::string id, std::string pw);
|
It is in the source file
User.cpp that you need to use the scope resolution operator and fully qualify the names of member functions because they are being implemented outside of the class.