The ERROR says calling the private constructor of the class is private within the context. What does that mean? How to call the private constructor of the class?
1 2 3 4 5 6 7 8 9
class hippo
{
public:
hippo(int z)
{
//code
}
~hippo(){}
hippo is the class here which I am calling.
hippo x = hippo(y); //I am getting the error here
How to resolve the above error. Suggestions are appreciated.
Nothing wrong with it. You need to show your actual code. I think your code might actually be calling a copy constructor.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
class hippo
{
public:
hippo(int z)
{
std::cout << "Constructed with " << z << '\n';
}
~hippo(){}
};
int main()
{
int y = 10;
hippo x = hippo(y);
}