Thread: Newbie class question

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    The larch
    Join Date
    May 2006
    Posts
    3,573
    You have already implemented all the methods of Die in the header, so there is nothing left to put into the "die.cpp" file (except perhaps the definition of unsigned Die::mInitiator?).

    You would just create Die instance(s) in main() (or any other function you like) and use it like Elysia has shown.

    By the way, it seems that your effort to reseed the random number generator for each Die object is rather useless. rand() relies on global state, so seeding it in one instance of Die resets the seed for all other instances of Die. You might just call srand in main() at the beginning of the code, remove the initialize function (and the static variable) and simply call rollDie in the constructor of Die instead.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  2. #2
    Registered User
    Join Date
    Jul 2008
    Posts
    2
    Thank you both!

    What part of the headerfile should be in the .cpp to make it work properly. I know how to call the class from main directly. But I want it to be a proper class with full .h and .cpp.

    And, yes I will study classes more. This is part of it, I am trying to get an example of how it works with a little more complicated headerfile.

    Again, thanks!
    Last edited by vastgoten; 07-31-2008 at 12:24 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. A question about class members and constructors
    By Megidolaon in forum C++ Programming
    Replies: 5
    Last Post: 01-30-2009, 03:01 PM
  3. Question about getting an info class from another Form
    By Joelito in forum C# Programming
    Replies: 0
    Last Post: 10-16-2006, 01:02 PM
  4. question about .net to 6.0 change causing errors
    By jverkoey in forum C++ Programming
    Replies: 17
    Last Post: 03-23-2004, 10:45 AM
  5. question about DLL's and class functions
    By btq in forum Windows Programming
    Replies: 2
    Last Post: 02-25-2003, 06:08 AM