I tried running this code in the compiler and it gave an output of "circle":
#include <iostream>
using namespace std;
class figure{
public:
void print(){cout << "figure";};
};
class circle: public figure{
public:
void print(){cout << "circle";};
};
int main() {
circle c;
c.print();
}
I did not set the print function as a virtual yet it still had the same effect. Is there a reason for that?