#include "Generator.h"
#include "Proxy.h"
Proxy::Proxy(int inputbits):Generator(inputbits)
{
}
Proxy::~Proxy()
{
}
Generator * Proxy::operator ->()
{
if(counter<=10)
return rPointer;
else
return 0;
}
//Proxy* Proxy::instance = 0;
Proxy* Proxy::getInstance()
{
static Proxy* instance;
return instance;
}
.
#ifndef PROXY_H
#define PROXY_H
#include "Generator.h"
class Proxy: private Generator
{
public:
~Proxy();
static Proxy* getInstance();
Generator * operator ->();
private:
Proxy();
Proxy(int);
int bits;
int counter;
Generator * rPointer;
};
#endif // GENERATORPROXY_H
These are my code for a singleton, what I am trying to do is I'd like to pass some argument to the constructor after I make an object of Proxy in main function as Proxy::Proxy(int inputbits):Generator(inputbits)
I was going to use getInstance function, but it didn't work. Please enlighten me if you have any idea. Thanks, what I am expecting to be able to do is, for example, in main function, Proxy px(3); <- I know this is not working, but I want to use something like this with any way.