随笔分类 - 课程—C++学习笔记
摘要:重载为成员函数 双目: class ClassName { public: DataType operator@(Parameter List); … }; DataType ClassName::operator@ (Parameter List) { … } aa@bb //or aa . op
阅读全文
摘要:https://www.jianshu.com/p/fca56d635091
阅读全文
摘要:工作目录不能有中文! 注意,打开的程序名称以及程序存放路径也都不能有中文!
阅读全文
摘要:需要注意的一点就是循环引用头文件会报这个错,例如 a.h include了b.h, 反过来b.h又include了 a.h。 https://blog.csdn.net/typename/article/details/7173550参考博文
阅读全文
摘要:如果想采用 Student *stu=new Student[3]; 这样的语句,一定要添加缺省构造函数。
阅读全文
摘要:众所周知,delete 会释放new出来的单个对象指针指向的内存,这个“释放”的含义就是将这一块内存标记为可用,但并不会删除其指向的值。 这就很有意思了,在Codeblocks中执行如下语句: Score* s=new Score(96,95); delete s; s->show(); 实际上还是
阅读全文
摘要:私有继承: 父类的公有成员和私有成员到了子类里全部私有。子类内部可以访问继承过来的公有成员(比如类内函数可以访问),但外部无法直接访问(如直接cout<<a.age()) 公有继承: 父类的公有成员和保护成员到了子类里访问属性不变,但类外只能访问公有成员。 保护继承: 父类的公有和保护成员可以在子类
阅读全文
摘要:endl:换行 fixed:用一般的方式输出浮点数(在iostream头文件里) specify that (for output sent to the cout stream) decimal format (not scientific notation) be used, and that
阅读全文
摘要:1.Responsibility Driven Design(责任驱动设计) 2. Behavior(行为) and State(状态) Instances(实例) and Classes(类) Coupling(耦合) and Cohesion(内聚) Interface(接口) an
阅读全文
摘要:主要是一些名词Q^Q 1.头文件:It is common to place struct type declarations with TypeNames in a (.h) header file and # include that file. 不要在头文件用using,这样的话可能导致某些c
阅读全文
摘要:1. Constructors(构造函数) 函数名即类名,无返回值,为对象开辟存储空间时自动调用。可使用初始化器:PlayingCard (Suits is, int ir) : suitValue (is), rankValue (ir) { } 2. Default Constructor(缺省
阅读全文