码迷,mamicode.com
首页 > 编程语言 > 详细

C++ syntax

时间:2016-01-24 09:14:47      阅读:169      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!