
c++
春日丶野穹
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
C++ 引用 const new
引用 引用相当于变量的别名,初始化之后不能修改引用的对象. 引用作为函数的返回值 #include <iostream> using namespace std; int n = 4; int & setValue() { return n; } int main() { setValue() = 40; // 相当于n = 40 cout<&...原创 2019-03-19 19:48:18 · 645 阅读 · 0 评论 -
C++构造函数
构造函数 构造函数并不负责空间,它只是用来初始化成员变量. 当用户没有定义构造函数时,编译常生成默认构造函数,默认构造函数不进行任何操作. 一个类可以有多个构造函数.多个构造函数之间成重载关系. #include <iostream> using namespace std; class Sample { int x; public: Sample(...原创 2019-03-19 21:07:53 · 268 阅读 · 0 评论 -
操作符重载
算术运算符重载 #include <iostream> using namespace std; class Complex { public: int real; int imag; Complex(int r, int i):real(r), imag(i){} Complex operat...原创 2019-03-20 17:38:30 · 199 阅读 · 0 评论