I was executing a program given in the notes, this was the error that occured:-
Below is the code:-
#include<iostream> using namespace std; class B{ public: virtual void m1() { cout<<"B::m1\n"; } virtual void m2() { cout<<"B::m2\n"; } }; class D :: B { public: void m1() { cout<<"D::m1\n"; } }; int main() { B *p; B b; D d; p = &d; // p is set to d's address p-> m1(); p-> m2(); p = &b; // p is set to b's address p-> m1(); p-> m2(); } // here is the error :-
e4.cpp:14:7: error: ‘D’ has not been declared 14 | class D:: B | ^ e4.cpp:15:1: error: expected unqualified-id before ‘{’ token 15 | { | ^ e4.cpp: In function ‘int main()’: e4.cpp:26:1: error: ‘D’ was not declared in this scope 26 | D d; | ^ e4.cpp:27:6: error: ‘d’ was not declared in this scope 27 | p = &d; // p is set to d's address