I was learning constructors when i encountered a error which i couldn't understood.
vector<int> myvector();
cout << myvector.size();
I was dealing with my own class first, and was getting Expression must have a class type
.
So i tried with C++ STL and was getting the same error.
What's more none of my constructors were printing anything when i did like this, so it understood its not calling, but there was no compilation error, if i just write vector<int> myvector();
My Sample code for the class i declared
class MyClass
{
public:
MyClass()
{
cout << "No paramter passed";
}
MyClass(string str)
{
cout << "String passed\n";
}
};
int main()
{
MyClass myobj();
return 0;
}
In this none of the constructors were called, neither compilation error.