Hi this isn't really a problem as there are ways around this.
I was wondering why this:
Code:
private:
std::string m_Name;
std::vector<std::string> nameList;
std::vector<int> gradeList;
};
GradeBook::GradeBook ( std::string name )
{
setName ( name );
nameList ( 10, "" ); // this is illegal
}
Is not allowed in C++? A constructor initalzes data members to starting values so why are you not allowed to tell the constructor I want the vector to hold 10 names and then make all the elements empty? ( "" )
It allowed me to declare the vector as a private member and name it but the only way to do what I need in the constructor is to remove it and create it in new function like this:
Code:
std::vector<std::string> nameList ( 10, "" );
This of course would work. I am not moaning I am only wondering why you cannot do such a simple thing inside a class constructor. Any help appreciated.