2013年10月25日

对象数组的应用

摘要: #include io代表输入输出,manip是manipulator(操纵器)的缩写(在c++上只能通过输入缩写才有效。)iomanip的作用:主要是对cin,cout之类的一些操纵运算子,比如setfill,setw,setbase,setprecision等等。它是I/O流控制头文件,就像C里面的格式化输出一样.▲ setprecision用法使用setprecision(n)可控制输出流显示浮点数的数字个数。C++默认的流输出数值有效位是6。如果setprecision(n)与setiosflags(ios::fixed)合用,可以控制小数点右边的数字个数。setiosflags(io 阅读全文

posted @ 2013-10-25 17:19 随风浪子的博客 阅读(310) 评论(0) 推荐(0) 编辑

对象的复制(复制构造函数)

摘要: # include # include using namespace std;class rect{private: double length; double width;public: rect(double length=0,double width=0); //rect(const rect&); //对象复制构造函可有可无 void output() { if(length>length>>width; }};rect::rect(double h,double w){ length=h; width=w;}//r... 阅读全文

posted @ 2013-10-25 16:53 随风浪子的博客 阅读(102) 评论(0) 推荐(0) 编辑

构造函数和析构函数程序举例

摘要: # include # include 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; tem 阅读全文

posted @ 2013-10-25 16:20 随风浪子的博客 阅读(167) 评论(0) 推荐(0) 编辑

导航