初始化的例子
// 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;
}
//
#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;
}