正在加载图片...
9.1 概述 int operator+(const A &x,int y){return x.getx(+y; int operator+(int y,A x){return x.getxO)+y; void main(void) 必须有关于类的对象 Aa(6), cout<"a+7="<<a+7<<"\n"; /调用int operator+(const A&,int) cout<<"8+a="<<8+a<<"n", /调用int operator+-(int,A) } 输出: a+7=13 8+a=14 77 9.1 概述 int operator+(const A &x, int y){ return x.getx()+y; } int operator+(int y, A x){ return x.getx()+y; } void main(void) { A a(6); cout<<"a+7="<<a+7<<"\n"; //调用int operator+(const A&, int) cout<<"8+a="<<8+a<<"\n"; //调用int operator+(int, A) } 输出: a+7=13 8+a=14 必须有关于类的对象
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有