C++输出操作符求值顺序
来源:互联网 发布:华硕网络控制器驱动 编辑:程序博客网 时间:2024/05/21 04:39
从右向左哦~ 其实,通过设置断点走一遍就知道了
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
class Matrix
{
public:
Matrix(int m,int n):a(m),b(n){}
Matrix(){}
friend Matrix operator + (const Matrix& pre, const Matrix& mat);
Matrix(const Matrix& A){ a=A.a;b=A.b;cout<<"拷贝构造函数被调用"<<endl;}
int getA(){return a;}
int getB(){return b;}
private:
int a,b;
};
Matrix operator + (const Matrix& pre, const Matrix& mat)
{
Matrix M;
M.a=pre.a+mat.a;
M.b=pre.b+mat.b;
return M;
}
int main(int argc, char* argv[])
{
cout<<"start:"<<endl;
Matrix A(1,3);
Matrix B(2,4);
Matrix C=A+B;
cout<<C.getA()<<(C.getB()+1)<<" "<<C.getB()<<endl;
system("pause");
return 0;
}
0 0
- cout输出操作符求值顺序
- C++输出操作符求值顺序
- C/C++中操作符的优先级和求值顺序
- C语言中的操作符优先级和求值顺序
- C/C++中操作符的优先级和求值顺序
- C++中,cout操作符求值顺序
- 操作符的优先级和求值顺序——C语言
- 关于C/C++种运算符的优先级,结合性以及操作数的求值顺序
- c语言表达式求值顺序
- C,C++表达式求值顺序
- C,C++表达式求值顺序
- C,C++表达式求值顺序
- C,C++表达式求值顺序
- C,C++表达式求值顺序
- C,C++表达式求值顺序
- C语言表达式求值顺序
- C,C++表达式求值顺序
- C,C++表达式求值顺序
- stl map底层之红黑树插入步骤详解与代码实现
- poj 1286 Necklace of Beads & poj 2409 Let it Bead(初涉polya定理)
- Android新手---对话框(一)
- python: scikit-image数字图像处理
- Spring & SpringSecurity 相关的文章
- C++输出操作符求值顺序
- SQLplus中arraysize设置.
- android开发之mac下jdk的安装及开发环境搭建
- java与scala集合相互转换
- AVL_tree的删除
- OCP 1Z0 052 9
- HAProxy+Keepalived实现Web服务器负载均衡
- spring配置datasource三种方式
- jQuery插件实现新浪微博自动底部加载