• 腾讯2016春招实习生(软件开发)笔试模拟卷


    #include <iostream>
    #include <stdio.h>
    using namespace std;
    
    class A {
        public:
            A(){ cout << "A constru" << endl; }
            ~A(){ cout << "A xigou" << endl; }
    };
    
    class B: public A {
        public:
            B() { cout << "B contru" << endl; }
            ~B() { cout << "B xigou" << endl; }
    };
    
    struct SA {
        void foo(){ printf("foo "); }
        virtual void bar() { printf("bar "); }
        SA(){bar();}
    };
    struct SB: SA {
        void foo() { printf("b_foo "); }
        void bar() { printf("b_bar "); }
    };
    
    int main() {
        A *pA = new B();
        delete pA;
        SA *p = new SB;
        p->foo();
        p->bar();
        return 0;
    }
    /*
     *结果为:
    A constru
    B contru
    A xigou
    bar foo b_bar 
     */
    
    

  • 相关阅读:
    The first appliaction for "Hello World!"
    zone
    learn to study
    深入理解 Angular 2 变化监测和 ngZone
    看看吧
    生命周期钩子
    一个简单的todo
    依赖注入
    @Output()
    @Input
  • 原文地址:https://www.cnblogs.com/tenlee/p/5321389.html
Copyright © 2020-2023  润新知