Well I understand the part that I will be getting some random value, but is theFoo()
constructor in the snippet acting just like the default public constructor which the compiler supplies when we have no constructor defined?
#include<iostream>
using namespace std ;
class Foo{
int i ;
public:
Foo(){
}
void disp(){
cout<<"i = "<<i ;
}
};
int main(){
Foo bar1,bar2 ;
bar1.disp();
cout<<"\n";
bar2.disp();
}
I have seen some people writing an empty constructor like this, but I could't understand exactly why/when is it to be used?