04 2012 档案

C++中异常处理
摘要:看了下thinking in c++ v2 中的 exception handling, 这里简单总结下C++语言层面exception handling理解1 . throw, try , catchthrow expression; 这是在程序普通地方用的, expression总是有一个类型的, 也就是说可以抛出任意一个 type 的 object;throw ; 是在 catch 语句里面使用的, 把接收到的object再次抛出, 当然在catch中也可以再抛出任意type的异常 1 #include <iostream> 2 using namespace std; 3 阅读全文

posted @ 2012-04-25 20:31 小宇2 阅读(2081) 评论(0) 推荐(0) 编辑

构造函数,析构函数不为public时
摘要:当constructor, destructor为protected时, 不允许实例化这个类,不管是在栈中还是在堆中,(但可以实例化派生类(protected 的 constructor可以在派生类中调用)) , 当在栈中实例化一个类时, 需要constructor和destructor都是public的, 而在堆中new时 ,需要constructor是public的, 而当调了delete时, 才需要destructor是public的 , 当constructor为private时, 不仅不允许实例化这个类, 也实例化不了派生类(private constructor只能在本类成员中调用 阅读全文

posted @ 2012-04-20 20:40 小宇2 阅读(932) 评论(0) 推荐(0) 编辑

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示