Hello there,
I have recently bought the GCC book. It's great and I am really enjoying it :). Anyways, let me ask my question.
Display All
As you can see from the comments in the code section, I am wondering whether virtual keyword makes any difference if it is typed in the derived class. I am also confused with the "override" keyword used in the page 65 of the book. As far as I know; if the signature of the method in the derived class is exactly the same, it is already overriding the "base method". So, what is the deal with this "override" keyword?
Thanks :).
I have recently bought the GCC book. It's great and I am really enjoying it :). Anyways, let me ask my question.
Source Code
- class A{
- public:
- virtual void VDraw(){ std::cout << "A" << std::endl; }
- };
- class B: public A{
- public:
- B(){}
- void VDraw(){ std::cout << "B" << std::endl; } // Do we need a "virtual" specifier here? Does it make any difference?
- };
- class C: public B{
- public:
- C(){}
- void VDraw(){ std::cout << "C" << std::endl; } // Do we need a "virtual" specifier here? Does it make any difference?
- };
As you can see from the comments in the code section, I am wondering whether virtual keyword makes any difference if it is typed in the derived class. I am also confused with the "override" keyword used in the page 65 of the book. As far as I know; if the signature of the method in the derived class is exactly the same, it is already overriding the "base method". So, what is the deal with this "override" keyword?
Thanks :).