c++ Singleton by reference use -


I have read some wiki in stack overflow, and I have written the following header file for my randomizer class: Class random {public: static Randomizer & amp; Example (zero); Int nextInt (int); Int nextInt (int, int); Int die; Double next double (zero); Four randomized (const std: string & amp;;); Private: Random (zero) {}; / * No implementation of the following methods * / Randomizer (Randomizer const & amp;;); Zero operator = (randomizer brace & amp;); };

I have also applied some methods inside the classroom, such as the next and the like.

I am unsure about how to give examples of this singleton class, that is how to write a test drive in the main ()?

I tried:

  int main () {Randomizer r; R = Radiimizer :: Example (); }   

The compiler says some errors:

  in the Randomizer.cpp file included: 11: 0: Randomizer.h: in the function ??? ? Int main (int, char **) a ????: Randomizer.h: 22: 9: error: a randomize :: Randomizer () a ???? Private is random (zero) {}; ^ Randomizer.cpp: 56: 16: Error: Randomomarer in this context; ^ Randomizer.cpp file included in: 11: 0: Randomizer.h: 25: 14: Error: An empty zero random :: operator = (Const Randimizer & amp;) ??? Private Zero operator is = (Radiimizer brace & amp;); ^ Randomizer.cpp: 57: 7: Error: R = RandOzer :: Example () in this context; ^   

Thanks for the help.

You are saying that you want a singleton but:

  Randomizer R;   

This creates a new example of Randomizer by attempting to call the default blank constructor. So you are not using it as a singleton, in addition you have declared the constructor private.

  r = randomizer :: instance ();   

Here you are trying to copy a single from a singleton, which you have explicitly declared private.

Perhaps you want to use it:

  Randisoner & amp; R = Radiimizer :: Example ()   

Probably a const randomm and amp; For example () method that is a temporary reference if the randomizer does not have a visible position in itself.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -