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; }
时间: 2024-12-23 13:14:07