C程序设计_对象分册(第3章)潘修改.pptVIP

  • 8
  • 0
  • 约9.38千字
  • 约 56页
  • 2017-04-25 发布于四川
  • 举报
C程序设计_对象分册(第3章)潘修改

第3章多态性;第3章多态性;3.1多态性的概念;3.2.1 运算符重载概述;3.2.1 运算符重载概述;3.2.1 运算符重载概述;3.2.2 双目运算符重载;C/C++程序设计教程--面向对象分册;【例3.2】定义复数类Complex,重载“+”运算符为它的成员函数 #include iostream class Complex { public: Complex (double r = 0, double i= 0) { real = r; image = i; } void print(); Complex operator+ ( const Complex c); private: double real, image; };;C/C++程序设计教程--面向对象分册;C/C++程序设计教程--面向对象分册;C/C++程序设计教程--面向对象分册;3.2.3 赋值运算符重载; void display( ) { coutbufferendl; } void set(char *string) { delete [ ] buffer; buffer= new char[strlen(string)+1]; strcpy(buffer, string);

文档评论(0)

1亿VIP精品文档

相关文档