
C++
daocaoren_
这个作者很懒,什么都没留下…
展开
-
C++函数传值方式
通过传值参数传值——按值传递 int abc(int a,int b,int c) { return a+b*c; } z=abc(2,x,y); a,b,c为函数的形参(也是传值参数);2,x,y为函数的实参。 其传参模式为: Created with Raphaël 2.1.2实参实参形参形参函数abc被执行前,通过复制构造函数传值函数abc执行结束后,调用析构函数,释放形参 ...原创 2018-03-24 20:11:21 · 1536 阅读 · 0 评论 -
运算符重载
运算符的重载是C++多态性的一种体现。通过重载运算符,可以使代码变得更加简洁易懂,符合人的思维习惯。例如,通过对数组类重载+运算符,就可以直接完成数组之间的相加。 下面是数组类的定义: template<class T> class matrix { friend ostream& operator<<(ostream&, const matrix...原创 2018-04-28 18:16:24 · 202 阅读 · 0 评论 -
new与malloc的区别
#include<iostream> #include<new> using namespace std; const int buf(512); int N(5); int a[buf] = { 1 }; int main() { cout << a[0] << endl; int *p1, *p2; p1 = new int[N]; ...原创 2019-09-30 10:57:57 · 289 阅读 · 0 评论