构造函数和析构函数程序举例
# include <iostream> # include <string> using namespace std; class A { public:A() { cout<<"constructing an object of A"<<endl; } ~A() { cout<<"Destructing an object of A"<<endl; } }; void temporary() { A b; } int main() { cout<<"----begin main---"<<endl; A a; temporary(); cout<<"*******"<<endl; A c; A d; cout<<"----end main---"<<endl; return 0; }
                    
                
                
            
        
浙公网安备 33010602011771号