Sunday, March 2, 2014

Initialization of data with different data types in class

#include<iostream>
using namespace std;
 class Test {
    int &t,i;
    char *str;
    const int x;
    static int y;
public:
    Test(int &t):t(t),i(0),str(new char[10]),x(10) {}  //Initializer list must be used
    int getT() { return t; }
};
 int Test::y=0;
int main() {
    int x = 20;
    Test t1(x);
    cout<<t1.getT()<<endl;
    x = 30;
    cout<<t1.getT()<<endl;
    return 0;
}

Vi Editor

VI EDITOR Move move in the editor: h right j up k  down l left move top shift +g gg down the line of the file :8 go to line 8 search /string...