Usually, in C/C++ we initialize variables like this
int roll_no=2235;
float sal=45000.60;
But in C++ we can initialize variables in another way as shown below and this notation of initializing variables is known as a class constructor notation
#include <iostream>
using namespace std;
int main()
{
int roll_no(2235);
float sal(45000.60);
cout << roll_no << endl;
cout << sal << endl;
return 0;
}
Output
2235
45000.6
Leave a Reply