August 4th, 2003, 04:16 AM
i get this error msg:
error C2512: 'RndNum' : no appropriate default constructor available
when im using this code:
// Implementing the reel.h file into reel.cpp //
// Construction/Destruction //
currentSymbol = ran.generateNumber();
im tryin to use my rndnum class to generate a randomnumber each time a reel is spun, have i gone the wrong way about this or is their a simple answer to my problem?
August 4th, 2003, 05:36 PM
It would help if u give the class definitions
August 4th, 2003, 07:19 PM
Most likely, you defined a constructor something like this:
RndNum(int a, double b)
Well, that means you have a constructor that takes two parameters. When you declare your RndNum variable here:
you will notice you did not provide the two parameters your constructor requires, e.g.:
RndNum ran(6, 5.25);
So, the compiler looked for a constructor you defined with no parameters, and it couldn't find one.
The rule is: if you don't define a constructor, the compiler will provide a default constructor, i.e. one with no parmaters, but if you define any constructor for your class, the compiler won't supply a default constructor for you.
Last edited by 7stud; August 4th, 2003 at 07:40 PM.