One problem with the typedef is that class Student
is an abstract class, so it cannot be default constructed, which is required for types that vectors can be composed of.
Another issue (say you removed the fact that class Student
is abstract) might be that the class isn't fully defined. You can, in fact, declare a typedef for a vector<>
with an incomplete class, but you wouldn't be able to actually use the typedef until the class was fully defined - except to declare pointers or references to the type.
In both a cases you may need to think about the class's overall design - you may want to have a vector<Student*>
instead so the vector can hold any type of student (using pointers since it can't hold an actual abstract Student object). As others have mentioned using smart pointers (but not std::auto_ptr<>
) would help with managing the lifetimes of object pointed to by the vector.