![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
小小小小小圆脸
这个作者很懒,什么都没留下…
展开
-
C++面向对象程序设计——类定义(1)
//学习如何构建类#include <iostream>#include <string>using namespace std;//类可以为空,但是为空时没有意义//一般类的数据成员默认时私有的//建立一个销售 项目--->销售单 类class Sales_item{public: Sales_item(std::string book...原创 2019-02-16 11:06:52 · 141 阅读 · 0 评论 -
C++面向对象程序设计——static 类成员
//static 也就是类中所有共享成员//static的优点:// 1、静态成员的名字是在类的作用域中,两个类有同样名称的静态成员,互不影响;//2、可以实时封装,类的成员可以是私有的//3、//定义static成员,使用类的static成员//static成员函数不可以使用this指针,静态成员函数不属于任何一个对象//#include <iostream>...原创 2019-02-18 22:11:01 · 217 阅读 · 0 评论 -
C++面向对象——友元
//友元//友元函数、友元类//三种友元:普通函数(非成员函数)、类、类的成员函数#include <iostream>#include <string>using namespace std;class Screen{public: friend int calcArea(Screen & screen); //声明为友元函数 ...原创 2019-02-18 21:25:51 · 305 阅读 · 0 评论 -
C++面向对象——类型转换构造函数(显/隐式)
//显式类型转换构造函数#include <iostream>using namespace std;class Complex{public: double real, imag; explicit Complex(int i){ //显式类型转换构造函数 cout << "IntConstructor called" <...原创 2019-02-22 23:40:48 · 345 阅读 · 0 评论 -
C++面向对象程序设计——复制构造函数
//复制构造函数只有一个参数,即对同类对象的引用//#include <iostream>using namespace std;class Complex{private: double real, imag;public: Complex(){ cout << "调用缺省无参构造函数" << endl; ...原创 2019-02-22 23:35:37 · 184 阅读 · 0 评论 -
C++面向对象程序设计——构造函数
//默认构造函数//隐世类型转换//类成员的显示初始化//构造函数//const常量、引用类型、没有默认构造函数的类类型都必须在初始化列表中定义#include <iostream>using namespace std;class Person{public: Person():age(0) {} Person(const std::str...原创 2019-02-17 16:28:08 · 304 阅读 · 0 评论 -
C++面向对象程序设计——类作用域
//类作用域//#include <iostream>#include <string>using namespace std;void doA(){ int a; a = 12;}void doB(){ int b; b = 99;}class First{public: int memi; ...原创 2019-02-17 14:28:02 · 160 阅读 · 0 评论 -
C++面向对象程序设计——(this指针)
//this指针的应用#include <iostream>#include <string>using namespace std;class Person{public: Person(const std::string &name, const std::string &addr){ //如果参数名字与原来数据对象名字相同...原创 2019-02-16 21:30:11 · 203 阅读 · 0 评论 -
C++面向对象程序设计———类定义(3)
//类声明-->前向声明//类定义//类对象#include <iostream>#include <string>using namespace std;class Screen; //类的前置声明class LinkScreen{ Screen *window; LinkScreen *next; //类的内部可以有指针型的成...原创 2019-02-16 15:47:16 · 165 阅读 · 0 评论 -
C++面向对象程序语言设计———类定义(2)
//类定义(2)//同一类型的多个数据成员,适用类型别名简化类//定义重载成员函数//显式指定inline内联成员函数#include <iostream>using namespace std; //导入名称空间//做窗口设计:窗口可以改变大小,多行文本框区域可以输入文字class Screen{ //1、写在类内部的函数都称为内联函数public: ...原创 2019-02-16 14:31:16 · 158 阅读 · 0 评论 -
C+面向对象程序设计——复制构造函数和复制操作符
//复制构造函数和赋值操作符#include <iostream>#include <string>#include <vector>using namespace std;class Sales_item{public: //普通构造函数 Sales_item(const std::string &book): isb...原创 2019-02-20 23:26:47 · 127 阅读 · 0 评论