Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class class1 {
- public:
- void test();
- void test2();
- };
- void class1::test() {
- std::cout << "Hello class1\n";
- }
- void class1::test2() {
- std::cout << "Hello class1 2\n";
- }
- class class2 : class1 {
- public:
- void test3();
- };
- void class2::test3() {
- std::cout << "Hello class2\n";
- }
- int main (int argc, char * const argv[]) {
- class1 *test = new class1();
- test->test();
- test->test2();
- /*
- Output is
- Hello class1
- Hello class1 2
- I want
- Hello class2
- Hello class1 2
- */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement