0
I need little help with dynamic_cast
I have a base class Student and a base class Teacher. I also have a class Demonstrator(students that assist teachers helping other students), that derives from both Student and Teacher. To differentiate demonstrators from regular students i tried: Demonstrator *d=dynamic_cast<Demonstrator *>(students[i]); //students is an array of objects from the class Student But the compiler sends an error message: error: cannot dynamic_cast '*(students + ((sizetype)(((long long unsigned int)i) * 8)))' (of type 'class Student*') to type 'class Demonstrator*'
2 odpowiedzi
+ 1
Is your "students" class polymorphic ? ( Means does it have any virtual function ? )
+ 1
Thanks. I forgot that.