Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class A {
- public:
- int a;
- A() : a(0) {};
- A(int v) : a(v) {};
- };
- class B : public A {
- public:
- int b;
- B(int v) : b(v) {};
- };
- void print(A* pointer) {
- std::cout << pointer->a << std::endl;
- }
- int main() {
- A a(1);
- B b(2);
- print(&a);
- print(&b);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement