How to override non-virtual function in C++

1 Answer

0 votes
#include <iostream>

using std::cout;
using std::endl;

class Base {
public:
	void print(void) { cout << "class Base" << endl; };
};

class Derived : public Base {
public:
	void print(void) { cout << "class Derived" << endl; };
};

int main(void)
{
	Derived o;

	o.print();

	return 0;
}

/*
run:

class Derived

*/

 



answered Apr 1, 2018 by avibootz
edited Apr 1, 2018 by avibootz

Related questions

1 answer 192 views
3 answers 194 views
194 views asked Jan 29, 2023 by avibootz
1 answer 179 views
2 answers 230 views
1 answer 221 views
...