virtual-functions tag

2 questions


1 answers
114 views
0
Why do you use the virtual method?

I started learning C++Isn't the virtual method used by the child class to override the parent class's method?You can just override it. Why do you have to use the virtual keyword?


1 answers
91 views
0
To call the virtual function of the parent class

In Bar, Foo's virtual void printStuff is overrideI'd like to sing printStuff() of Foo.In Java, we could've used super.printStuff() togetherHow do I use it in C++?class Foo{public: int x; virtual void ...


© 2024 OneMinuteCode. All rights reserved.