现在的位置: 首页 > 综合 > 正文

初始化的例子

2012年12月04日 ⁄ 综合 ⁄ 共 619字 ⁄ 字号 评论关闭
// initialtest.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>

using namespace std;

class iniT
{
public:
    int ia;
    //iniT()
    //{
    //    cout<<"i am iniT"<<endl;
    //}
};

int outmain;

iniT test;

class other
{
public:
    iniT otheriniT;
};

other othertest;

int _tmain(int argc, _TCHAR* argv[])
{
    cout<<"i am iniT's ia "<<test.ia<<endl;
    cout<<"i am outmain "<<outmain<<endl;

    int innermain;
    cout<<"i am innermain "<<innermain<<endl;

    iniT innerT;
    cout<<"i am innerT's ia "<<innerT.ia<<endl;

    cout<<"i am othertest "<<othertest.otheriniT.ia<<endl;

    other innerother;

    cout<<"i am innerother "<<innerother.otheriniT.ia<<endl;
    
    getchar();
    return 0;
}

抱歉!评论已关闭.