Hi! First of all, please excuse my english level, it's not my native language.
Now, I'm creating a class and I have an attribute that has to be a list. My class is "Student", and the attribute that I want to be a List type is actually a class named "Regular_Subjects", so I did it like this:
(The following code its Student.h file)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#ifndef Student_H
#define Student_H
#include <list>
class Student
{
protected:
string NumMatricula;
string RutAlumno;
string NomAlumno;
string AnoIngreso;
list<Regular_Subjects> Subjects;
|
Please ignore all of the string attributes. As I said, I have a "Regular_Subjects" class that has its own information and I need that every Student has a list of Subjects with all that information.
Is it right to declare it like that?
And if so, where should I use this lines?
list<Regular_Subjects>::iterator P;
P = Subject.begin();
I've found several examples using and explaining Lists in main function, but I don't know if I can do the same in a class.
For the record, I instance the constructor, getters and setters on a Student.cc file.
I hope I explained myself clear, I've been looking for a solution or and explanation but I can't find it and it's an assignment :(