f0914.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:1k
源码类别:
C#编程
开发平台:
Visual C++
- //=====================================
- // f0914.cpp
- // destruction order
- //=====================================
- #include<iostream>
- using namespace std;
- //-------------------------------------
- class A{
- public:
- A(){ cout<<"A->"; }
- ~A(){ cout<<"<-~A"; }
- };//------------------------------------
- class B{
- public:
- B(){ cout<<"B->"; }
- ~B(){ cout<<"<-~B"; }
- };//------------------------------------
- class C{
- public:
- C(){ cout<<"C->"; }
- ~C(){ cout<<"<-~C"; }
- };//------------------------------------
- void func(){
- cout<<"nfunc: ";
- A a;
- cout<<"ok->";
- static B b;
- C c;
- }//--------------------------------------
- int main(){
- cout<<"main: ";
- for(int i=1; i<=2; ++i){
- for(int j=1; j<=2; ++j)
- if(i==2) C c; else A a;
- B b;
- }
- func(); func();
- }//====================================