首页 > 编程语言 > 详细

C++ syntax

时间:2016-01-24 09:11:33      阅读:142      评论:0      收藏:0      [点我收藏+]

new:

int *a = new int[size];

int **a = new int*[size];

 

运算符重载:

class Complex
{
    public:
        int a,b;
};

Complex operator+(Complex &x, Complex &y){ // x+y
    Complex c;
    c.a = x.a + y.a;
    c.b = x.b + y.b;
    return c;
}

ostream &operator<<(ostream &os, Complex &x){  //cout<<x<<endl;
    os<<x.a<<"+i"<<x.b;  
// this is to tell the compiler how to put a complex into the outputstream(ostream)
return os; }

 

C++ syntax

原文:http://www.cnblogs.com/XingyingLiu/p/5154532.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!