- #1
yungman
- 5,718
- 241
I am copying some program from youtube videos. This is the program I copied:
I don't know what is :x(a) in line 5 .
I really don't even understand line 5,
Never learn this, don't even know the name to search online. Please help
Thanks
C++:
#include <iostream>
using namespace std;
class Base
{ int x;
public: Base() {} Base(int a) :x(a) { }
int get(){return x;}
void set(int a){x=a;}
};
int main()
{ Base b1; Base b2(10);
b2.get(); b2.set(20); return 0;
}
I don't know what is :x(a) in line 5 .
I really don't even understand line 5,
Base() {} Base(int a) :x(a) { }
what is this?Never learn this, don't even know the name to search online. Please help
Thanks