In the below two codes why the first code's object of class student "s2" is not created whereas object "s2" of code 2 is created. Why are just the "()" creating such difference?
///////////////CODE 1/////////////////
#include <iostream>
using namespace std;
class Student
{
int marks;
public:
Student()
{
cout << "In" << endl;;
}
Student(int x)
{
cout << "Out" << endl;
marks = x;
}
};
int main()
{
Student s1(100);
Student s2();
Student s3 = 100;
return 0;
}
//////////////////////////////////////
This is another code in which the "()" are absent i
///////////////CODE 2/////////////////
#include <iostream>
using namespace std;
class Student
{
int marks;
public:
Student()
{
cout << "In" << endl;;
}
Student(int x)
{
cout << "Out" << endl;
marks = x;
}
};
int main()
{
Student s1(100);
Student s2;
Student s3 = 100;
return 0;
}
//////////////////////////////////////