what do this error mean?
Code:error C2084: function 'int __thiscall dice::numSides(void)' already has a body
what do this error mean?
Code:error C2084: function 'int __thiscall dice::numSides(void)' already has a body
You probably have two functin declarations or definitions of the numsides() in your dice class
You probably declare the same function in two different places. Post your code.
ok, my teacher had us split the dice.h into dice.h and dice.cpp, and include the dice.cpp in with the dice.h, I think that might be my problem, is there a way make this work without merging them back together
Your function schould be declared in dice.h like this
void DoSomething();
and defined in your dice.cpp
void DoSomething()
{
bla bla;
}
include your dice.h in the top of your dice.cpp like this
#include "dice.h"
yeah, I did that
How about if you help us to help you and post some code
dice.h
dice.cppCode:#ifndef _DICE_H #define _DICE_H class dice{ public: dice(int sides); int roll(); int numSides(); int numRolls(); private: int mySides; int myRollCount; }; #endif
Code://dice.cpp #include <stdlib.h> #include <time.h> #include <limits.h> #include "dice.h" dice::dice (int sides) { long time = clock(); srand(time % INT_MAX); mySides = sides; } int dice::roll() { return (rand() % mySides) + 1; } int dice::numSides() { return mySides; } int dice::numRolls() { return myRollCount; }
I got it going, thanks for the help