In ContainerTest.h
I have the following singleton class defined:
class ContainerTest
{
private:
ContainerTest()
{
test = InitializeTest();
}
ContainerTest(const ContainerTest&) = delete;
ContainerTest(ContainerTest&&) = delete;
ContainerTest& operator=(const ContainerTest&) = delete;
ContainerTest& operator=(ContainerTest&&) = delete;
public:
std::vector<uint32_t> test;
static ContainerTest& GetInstance()
{
static ContainerTest rhc;
return rhc;
}
};
I am confused about whether only one instance of ContainerTest will exist throughout my program.
I.e., if two cpp files A.cpp
and B.cpp
both include ContainerTest.h
will there be one instance of ContainerTest created, or two instances? Can someone explain this? And if there's two instances created (one for A and B's translation unit) how can I prevent this?