So I have the following code:
#include<iostream>
using namespace std;
class baseClass
{
public:
int objID;
/*baseClass()
{}
*/
};
int main(int argc, char** argv)
{
baseClass bcObj;
cout << "bcObj.objID: " << bcObj.objID << endl;
return 0;
}
Now if I try to run this, I get a runtime error about using uninitialized variable. But if I add a default constructor (uncomment the constructor), it works fine. It still prints out a garbage value, but it prints with no runtime errors.
Why is this difference? The default constructor is not doing anything to the objID. I'm using visual studio 2013 (language extensions disabled).
Thank you.