#include<iostream>
class A1{
void f1() { std::cout << "print f1" << std::endl; }
public:
void f2() { std::cout << "print f2" << std::endl; }
void f5() { f1(); }
protected:
void f3() { std::cout << "print f3" << std::endl; }
};
class A2 : public A1{
public:
void f4() { f3(); }
};
int main(){
A1 obj;
A2 obj1;
obj1.f4();
obj1.f2();
obj1.f5();
obj.f2();
obj.f5();
return 0;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter