I'm trying to put together and understand Singleton design pattern in c++. For some reason I am receiving error. and maybe someone might be able to help and explain what is happening.
#include <iostream>
#include <string>
class Car{
public:
static Car* getInstance(){
instance = new Car;
return instance;
}
private:
Car(){
std::cout<<"we made car object\n";
}
Car(const Car&);
static Car *instance;
};
int main(){
Car test;
return 0;
}
so when i try compiling this code I am getting an error when trying to create a Car object in my main class: error: 'Car ::Car()' is private within this context.
i am compiling using g++ -std=c++14