Yes. You can initialize multiple variables in the same statement. Refer to the previous post and try out the following in Visual Studio Community 2017 (free) :
This is also possible:
This one as well possible:
The result of running this is shown here:
int ix = 5, iy = 6;
cout << ix << "," << iy;
cout << ix << "," << iy;
cout << "\n";
int iz(7), izz{ 8 };
cout << iz << "," << izz;
cout << "\n";
cout << iz << "," << izz;
cout << "\n";
This one as well possible:
int a = 100, b(50), c{ 100 };
cout << "a= " << a << " b= " << b << " c= "<< c;
cout << "\n";
cout << "a= " << a << " b= " << b << " c= "<< c;
cout << "\n";
The result of running this is shown here:
Here is a copy of the code.
No comments:
Post a Comment