error C2228: left of '.function' must have class/struct/union

I am trying to use iterators to navigate through a list representing table rows. Lines pointed to in output dialog are in select() attached below.


The classes in question:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class Grades{
public:
	/**
		  | id | term | year | grade |
	*/

	std::list<std::string> id_column;
	std::list<std::string> term_column;
	std::list<std::string> year_column;
	std::list<std::string> grades_column;

	//Constructor default

	void add_new(std::string id, std::string term, std::string year, std::string grade);
	void print_table();
};

class Students{
public:
	/**
		  | id | first | last |
	*/

	std::list<std::string> id_column;
	std::list<std::string> first_name;
	std::list<std::string> last_name;

	//Constructor default

	void add_new(std::string id, std::string first, std::string last);
	void print_table();
};


The function in question:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
void select(std::string table, std:: string attribute, std::string value){
	/****students table****/
	if (table == "students"){
		//initializing iterators
		std::list<std::string>::iterator id_column_iterator = Students::id_column.begin();  /*****this is line 66 as per output dialog******/
		std::list<std::string>::iterator first_name_iterator = Students::first_name.begin();
		std::list<std::string>::iterator last_name_iterator = Students::last_name.begin();

		//iterating through row values until a match is found in a method similar to table print functions
		do{
			if(attribute == "id" && *id_column_iterator == "value")
				std::cout << *id_column_iterator << "," << *first_name_iterator << "," << *last_name_iterator << "\n";
			else if(attribute == "first" && *first_name_iterator == "value")
				std::cout << *id_column_iterator << "," << *first_name_iterator << "," << *last_name_iterator << "\n";
			else if(attribute == "last" && *last_name_iterator == "value")
				std::cout << *id_column_iterator << "," << *first_name_iterator << "," << *last_name_iterator << "\n";

			++id_column_iterator;
			++first_name_iterator;
			++last_name_iterator;
		}while (id_column_iterator != Students::id_column.end());
	}/**end students table**/

	/****grades table****/
	else if (table == "grades"){

	//initializing iterators
		std::list<std::string>::iterator grades_column_iterator = Grades::grades_column.begin();/****this is line 89****/
		std::list<std::string>::iterator id_column_iterator = Grades::id_column.begin();
		std::list<std::string>::iterator year_column_iterator = Grades::year_column.begin();
		std::list<std::string>::iterator term_column_iterator = Grades::term_column.begin();

		//iterating through row values until a match is found in a method similar to table print functions
		do{
			if(attribute == "id" && *id_column_iterator == "value")
				std::cout << *id_column_iterator << "," << *term_column_iterator << "," << *year_column_iterator << "," << *grades_column_iterator;
			else if(attribute == "term" && *term_column_iterator == "value")
				std::cout << *id_column_iterator << "," << *term_column_iterator << "," << *year_column_iterator << "," << *grades_column_iterator;
			else if(attribute == "year" && *year_column_iterator == "value")
				std::cout << *id_column_iterator << "," << *term_column_iterator << "," << *year_column_iterator << "," << *grades_column_iterator;
			else if(attribute == "grades" && *grades_column_iterator == "value")
				std::cout << *id_column_iterator << "," << *term_column_iterator << "," << *year_column_iterator << "," << *grades_column_iterator;

			++id_column_iterator;
			++grades_column_iterator;
			++term_column_iterator;
			++year_column_iterator;
		}while (id_column_iterator != Grades::id_column.end());

	}/**end grades table**/

	else
		std::cout << "Error! " << attribute << " should be \"students\" or \"grades\" \n";
}




1>------ Build started: Project: Tables, Configuration: Debug Win32 ------
1>Compiling...
1>tablefunctions.cpp
1>c:\users\forrest\documents\visual studio 2008\projects\tables\tables\tablefunctions.cpp(66) : error C2228: left of '.begin' must have class/struct/union
1>c:\users\forrest\documents\visual studio 2008\projects\tables\tables\tablefunctions.cpp(67) : error C2228: left of '.begin' must have class/struct/union
1>c:\users\forrest\documents\visual studio 2008\projects\tables\tables\tablefunctions.cpp(68) : error C2228: left of '.begin' must have class/struct/union
1>c:\users\forrest\documents\visual studio 2008\projects\tables\tables\tablefunctions.cpp(82) : error C2228: left of '.end' must have class/struct/union
1>c:\users\forrest\documents\visual studio 2008\projects\tables\tables\tablefunctions.cpp(89) : error C2228: left of '.begin' must have class/struct/union
1>c:\users\forrest\documents\visual studio 2008\projects\tables\tables\tablefunctions.cpp(90) : error C2228: left of '.begin' must have class/struct/union
1>c:\users\forrest\documents\visual studio 2008\projects\tables\tables\tablefunctions.cpp(91) : error C2228: left of '.begin' must have class/struct/union
1>c:\users\forrest\documents\visual studio 2008\projects\tables\tables\tablefunctions.cpp(92) : error C2228: left of '.begin' must have class/struct/union
1>c:\users\forrest\documents\visual studio 2008\projects\tables\tables\tablefunctions.cpp(109) : error C2228: left of '.end' must have class/struct/union
1>Build log was saved at "file://c:\Users\Forrest\Documents\Visual Studio 2008\Projects\Tables\Tables\Debug\BuildLog.htm"
1>Tables - 9 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


My first guess (after some google searching this error message) is it has something to do with the scope in which I declare those iterators, but I'm not quite sure how to fix it in this case. Any guidance would be appreciated.
Students i_am_a_student, i_am_a_student_too_but_different_than_you;
¿do you understand that you can have several objects from the same class?
¿who is `Students::id_column' referring to?
I'm not quite sure what you mean by that. I referring to the object in class Students
1
2
Students foo, bar, lot[42];
select("students", "id", "");
¿which one? ¿foo, bar, lot[13]?
Topic archived. No new replies allowed.