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

743656-20160325222130542-1253977452.png

743656-20160325222140714-462205230.png

743656-20160325222147198-303266344.png

743656-20160325222153698-1218210288.png

743656-20160325222200104-938813395.png

743656-20160325222206308-94098832.png

743656-20160325222213667-236136162.png

743656-20160325222219417-1934024536.png

743656-20160325222225151-331977851.png

743656-20160325222231323-844479312.png

#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 
 */

743656-20160325222238151-814228933.png

743656-20160325222251276-1660482148.png

743656-20160325222258104-523382841.png

转载于:https://www.cnblogs.com/tenlee/p/5321389.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值