71、72、73

来源:互联网 发布:广电网络运维工作总结 编辑:程序博客网 时间:2024/05/21 01:45
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <memory>
using namespace std;
class SomeClass
{
public:
 SomeClass(string name):str(name){cout << str <<": In construct function."<<endl;}
 ~SomeClass(){cout<< str <<": In Destruct function."<<endl;}
 SomeClass(SomeClass &){cout<<str <<": In copy construct function."<<endl;}
 SomeClass & operator = (SomeClass &){cout<<str <<": In assignment function."<<endl;return *this;}
private:
 string str;
};
int main()
{
 auto_ptr<SomeClass> ptr1(new SomeClass("ptr1"));
 auto_ptr<SomeClass> ptr2(new SomeClass("ptr2"));
 *ptr2 = *ptr1;
 {
  auto_ptr<SomeClass> ptr3(ptr2);
  ptr1 = ptr3;
 }
 return 0;
}
#include <iostream>
using namespace std;
class CException
{
public:
 CException() {}
    virtual ~CException() {}
 void Reason() {cout << "CException" << endl;}
};
void fn1()
{
 throw CException();
}

int main()
{
 try {
  fn1();
 } catch (CException& ce) {
  ce.Reason();
    }
 
 return 0;
}