Debian 6.0 安装过程 及中文乱码
2012-03-30 20:15
423 查看
#include<iostream> using namespace std; int main() { int i1=1; double d1=3.21; cout<<"int->"<<i1<<endl<<"double->"<<d1<<endl; system("pause"); } #include<iostream> using namespace std; class person { public: void Display() { cout<<"name: "<<_name<<endl; cout<<"sex: "<<_sex<<endl; cout<<"age: "<<_age<<endl; } char* _name; char* _sex; int _age; }; int main() { person p; p._name="zhangsan"; p._sex="nan"; p._age=31; p.Display (); system("pause"); return 0; } 实例化 #include<iostream> using namespace std; class person { public: void Display() { cout<<"name: "<<_name<<endl; cout<<"sex: "<<_sex<<endl; cout<<"age: "<<_age<<endl; } public: char* _name; char* _sex; int _age; }; void test() { person p; p._name ="hhh"; p._sex ="男"; p._age =20; p. Display(); } int main() { test(); system("pause"); return 0; } 日期类 构造函数 #include<iostream> using namespace std; class Date { public : Date(int year,int month,int day) { cout<<"构造函数"<<endl; _year=year; _month=month; _day=day; } void SetDate(int year,int month,int day) { _year=year; _month=month; _day=day; } void Display() { cout<<_year<<"-"<<_month<<"-"<<_day<<endl; } private : int _year; int _month; int _day; }; void test1() { Date d1(2015,2,11); d1.Display (); } int main() { test1(); system("pause"); return 0; } 重载 #include<iostream> using namespace std; class Date { public : Date(int year,int month,int day) { cout<<"构造函数"<<endl; _year=year; _month=month; _day=day; } Date(int year,int month) { _year=year; _month=month; _day=11; } Date(int year) { _year=year; _month=12; _day=11; } void SetDate(int year,int month,int day) { _year=year; _month=month; _day=day; } void Display() { cout<<_year<<"-"<<_month<<"-"<<_day<<endl; } private : int _year; int _month; int _day; }; void test1() { Date d1(2015,2,11); Date d2(2015,2); Date d3(2015); d1.Display (); d2.Display (); d3.Display (); } int main() { test1(); system("pause"); return 0; } 拷贝构造 #include<iostream> using namespace std; class Date { public : Date(int year,int month,int day); Date(const Date& d) { cout<<"拷贝构造函数"<<endl; _year=d._year ; _month=d._month ; _day=d._day ; } void SetDate(int year,int month,int day) { _year=year; _month=month; _day=day; } void Display() { cout<<_year<<"-"<<_month<<"-"<<_day<<endl; } private : int _year; int _month; int _day; }; Date::Date(int year,int month,int day) { cout<<"构造函数"<<endl; _year=year; _month=month; _day=day; } void test1() { Date d1(2015,2,11); d1.Display (); Date d2(d1); d2.Display (); } int main() { test1(); system("pause"); return 0; } 析构函数 #include<iostream> using namespace std; class Arr { public: Arr(size_t size) { _prt=(int*)malloc(sizeof(int)*size); } ~Arr() { free(_prt); } private: int* _prt; }; int main() { Arr(20); system("pause"); return 0; } 复数类 #include<iostream> using namespace std; class Complex { public : Complex(double real=0,double image=0) { cout<<"Complex (double real=0,double image=0)"<<endl; _real=real; _image=image; } ~Complex() { cout<<"~Complex()"<<endl; } Complex(const Complex& d) { cout<<"Complex(comst Complex& d)"<<endl; _real=d._real ; _image=d._image ; } Complex& operator=(const Complex& d) { cout<<"operator=(const Complex& d)"<<endl; if(this!=&d) { this->_real=d._real; this->_image=d._image; } return *this; } void Display() { cout<<"Real:"<<_real<<"--Image:"<<_image<<endl; } private: double _real; double _image; }; void test() { Complex d1(1.1,3.3); d1.Display (); } int main() { test(); system("pause"); return 0; }
相关文章推荐
- Debian 6.0 安装过程 及中文乱码
- Debian 6.0 安装过程 及中文乱码
- gentoo 上安装oracle ( 安装过程中文乱码我解决 原创)
- MySql安装过程以及中文乱码解决办法
- debian服务器解决中文安装后出现乱码的问题
- debian6.0安装后中文字体显示不正常的解决办法
- 【debian】解决debian中文安装后出现乱码的问题
- 开源电商 OFBiz (Mysql)Idea安装过程及问题(中文乱码,500 GenericEntityException jdbc,Visitor错误处理)
- debian、ubuntu下安装fencview.vim插件,查看中文不乱码
- Debian 安装完后控制台中文乱码解决
- Debian安装时选择中文后进入系统出现乱码问题的解决
- 解决Debian安装后中文乱码
- 中文安装debian后出现乱码,如何恢复成英文
- debian安装后 中文名称的文件及文件夹显示为方块 乱码等
- 解决在Linux6.1下安装Oracle-11g-R2时的中文乱码问题-(图形安装过程中)
- ubuntu下安装oracle sql developer及中文乱码解决
- debian 8安装过程中遇到的问题总结
- pdf阅读器xpdf的安装与中文乱码问题
- sublime text2 使用技巧-安装插件-中文乱码问题解决
- 如何在Debian下手工安装中文字体