RPG Character Generator

This is a discussion on RPG Character Generator within the C++ Programming forums, part of the General Programming Boards category; joshdick, they can do everytihng that classes can do...

  1. #16
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    joshdick, they can do everytihng that classes can do

  2. #17
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    Originally posted by Polymorphic OOP
    joshdick, they can do everytihng that classes can do
    Really? I've never seen structs with constructors or functions. Could you please show me an example of functions in a struct coded out for me? Thanks in advance.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  3. #18
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330

    ~

    Code:
    struct HelloWorld {
    private:
         int hello, world;
    public:
         HelloWorld() : hello(0), world(1) {}
         HelloWorld(int x, int y) : hello(x), world(y) {}
         void PrintHello(void) { cout << hello << endl; }
         void PrintWorld(void) { cout << world << endl; } 
    };

  4. #19
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    Wow. I've never seen that. I've always seen structs used in a much simpler way than classes. Hmm. So why use one over the other? I know that structs default to public and classes to private, but besides that, what's the difference between the two?
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  5. #20
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    structs also default to public inheritance while classes default to private inheritance.

    other than those differences, nothing.

  6. #21
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330

    ~

    There is no other difference. Structures were included for compatibility with C code.

  7. #22
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    Huh. Thanks for enlightening me, guys. So, does that mean that I could create a class that just had public data members without any functions or constructors/destructors?
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  8. #23
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330

    ~

    Yes.

  9. #24
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    Huh, this is really quite a revelation to me.

    Um, so, if there's very little difference between structs and classes, why were classes introduced to C++? Why couldn't C++ just continue using structs?
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  10. #25
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    because C++ classes are very different from C structs. C structs aren't capable of member functions, etc.

    Why they introduced the name "class?" It certainly wasn't a necissary addition -- probably just to further emphasize the differences between C++ classes and C structs. The reason "structs" still exist is for compatability.

  11. #26
    UNBANNED OneStiffRod's Avatar
    Join Date
    Jan 2002
    Posts
    669
    C structs and C++ structs are diff from each other.
    My Avatar says: "Stay in School"

    Rocco is the Boy!
    "SHUT YOUR LIPS..."

  12. #27
    Registered User
    Join Date
    Dec 2001
    Posts
    479

    Who says that this is a school project or that I am even in school still? I think that was a bad assumption Pode.
    i was thinking of this

    I am not talking about making a computer game here...more of an application for the pen and paper type of game. Any other ideas?
    i meant you should go to your teacher (or your mom) and ask them to teach you to write.

  13. #28
    Registered User
    Join Date
    Dec 2002
    Posts
    15
    Originally posted by pode

    i meant you should go to your teacher (or your mom) and ask them to teach you to write.

    You are really out of it....I am not in school anymore (been a LONG TIME) and I am old enough that I don't need my Mom (not like she knows how to program or even turn on a computer).

    All I was asking was some simple ideas if anyone in these forums has done anything similar. I can think of some ideas on how to do it but stuff like printing out of the character sheet with the stats they want on it stumps me right now as I have not done much programming with printing out to a printer (graphics, bitmaps, etc.)

  14. #29
    Registered User
    Join Date
    Dec 2001
    Posts
    479
    u was asking for help with pen and paper
    so i thought maybe u could'nt write(with pen)
    so i told u to ask your teacher(that's what they're for)
    or your mom(if she got the time)

  15. #30
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    I usually use the different keywords just for mental note. I use structs for anything that is just storing variables and classes for anything else. But you could just use all structs or all classes.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 11
    Last Post: 10-07-2008, 06:19 PM
  2. about wide character and multiple byte character
    By George2 in forum C Programming
    Replies: 3
    Last Post: 05-22-2006, 08:11 PM
  3. pipe
    By smart girl in forum C Programming
    Replies: 4
    Last Post: 04-30-2006, 09:17 AM
  4. LoadFromFile() from a txt
    By Snoopy104 in forum C++ Programming
    Replies: 6
    Last Post: 03-14-2006, 09:05 AM
  5. Any help would be appreciated.....
    By SprinterSteve in forum C Programming
    Replies: 6
    Last Post: 05-01-2003, 09:25 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21