systemtap/tests/Regression/RHEL6Feature-cpp-inheritance/classes.cpp

57 lines
857 B
C++
Raw Normal View History

#include <iostream>
class A{
public:
void one(){ std::cout << "A::one" << std::endl; }
void two(){ std::cout << "A::two" << std::endl; }
virtual void three() { std::cout << "A::three" << std::endl; }
virtual void four() { std::cout << "A::four" << std::endl; }
};
class B : public A{
public:
void one() { std::cout << "B::one" << std::endl; }
int one(int a) { std::cout << "B::one" << std::endl; }
virtual void three() { std::cout << "B::three" << std::endl; }
};
int main(){
A a;
B b;
A *ap = new A();
A *apb = new B();
B *bp = new B();
a.one();
a.two();
a.three();
a.four();
b.one();
b.two();
b.three();
b.four();
ap->one();
ap->two();
ap->three();
ap->four();
apb->one();
apb->two();
apb->three();
apb->four();
bp->one();
bp->two();
bp->three();
bp->four();
return 0;
}