This is one expanded class example simulating a an easy school food registration / screen program. I"m acquiring the error C2228: left the "" must have actually class/struct/union all over the location within two .cpp files. I"m not totally sure what no to include, for this reason I"ll provide you the accompanying .h documents as well. (I"ve likewise got part stuff commented out that"s creating other errors... Ns made the failure of not test compiling as I to be going. If you view stuff dorn in various other areas, I"d it is in happy to know.) My education and learning in C++ is still fairly basic, but I"m acquiring there :P.

You are watching: Left of must have class/struct/union

I"ve excellent a bunch of browsing Google and also the like, however nothing appears to deal with my problem, at the very least that I"m familiar enough to recognize. Any aid would be considerably appreciated.I"m making use of Visual Studio 2010 (full version).User.h
123456789101112131415161718192021222324#pragma once// #include "GlobalData.h"#include "Course.h"#include #include #include class Course;class Userpublic:std::string name;std::string id;std::string pw;int permission;std::vector courseList;User::User();User::User(std::string name, std::string id, std::string pw);// void User::DropCourse(int courseid);// void User::AddCourse(Course course);// void User::ShowCourseList();;

123456789101112131415161718192021#pragma once#include "User.h"#include #include #include course User;class Coursepublic:User* instructor;std::string name;int courseid;std::vector roster;Course::Course(std::string name, int courseid);Course::Course(User instructor, std::string name, int courseid);Course::Course(User instructor, std::string name, int courseid, std::vector roster);;

1234567891011121314151617181920#include "Course.h"Course::Course(std::string n, int c) = n;Course::Course.courseid = c;Course::Course(User i, std::string n, int c) = n;Course::Course.courseid = c;Course::Course.instructor = i;Course::Course(User i, std::string n, int c, std::vector r) = n;Course::Course.courseid = c;Course::Course.instructor = i;Course::Course.roster = r;

(I"m likewise getting the red squiggly under the i in the above Course::Course.instructor = i;, which placing a & prior to doesn"t seem come solve.)Now, the output dialog:
Last edited on Oct 16, 2011 at 12:50am UTC
Oct 16, 2011 at 3:28am UTC
1> User.cpp1>g:webasvisor 3.0webasvisor 3.0user.cpp(5): error C2228: left the ".name" must have class/struct/union

In User.cpp on line 3 User::User, the limit resolution operator areas you inside the User class scope and so from there on to the end of the duty class members room accessed straight without the border resolution operator. Change line = "";toname = "";What around the compiler"s error blog post that
? There in reality is implicitly a course to the left the .name, the this reminder which points come the object being instantiated. The is, writing:name = ""; is the indistinguishable of this->name = ""; which consequently is tantamount to ( *this ).name;. Still, girlfriend shouldn"t usage the this tip in this case since it is currently there implicitly.The other errors appear to be similar.Also, in User.h in currently 19
and 20 the an initial User in every line is redundant because you are already within the User class scope. Change lines 19 and also 20 to:
It is in the source record User.cpp that you need to use the border resolution operator and fully qualify the name of member functions because they are being imposed outside the the class.
Last edited on Oct 16, 2011 at 3:31am UTC
Oct 16, 2011 at 4:30am UTC
Wow, I had no idea. My instructor has been attempting come teach united state the most "verbose" means to program, so i didn"t think to depend on the implied.

See more: Will Wearing Old Retainer To Shift Teeth Back Into Place? Can You Wear An Old Retainer To Straighten Teeth

Thanks very much!
Topic archived. No new replies allowed.



Home web page | Privacy policy©, 2000-2021 - all rights booked - v3.2Spotted an error? contact us