Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Class

Class

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestionc++game-devhelp
16 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SilverShalkin
    wrote on last edited by
    #1

    Ok... Ive bean experimenting with classes "saying that i do not know anything (at all) about classes, its bean a confusing process" When i try to learn somthing I usually pinpoint the thing that i need to learn and start experimenting with it... "i do look through the MSDN a bunch and the help tutorial that VC++ 6.0 came with but if your unsuccesfull try the forums :)." My question is... to be responded by tutorial link or whatever... How do you use a class... why do you use them... What does Publuc do... What does private do... Do classes require any header files? Right now im doing somthing like: class monster; { //somthing here } my idealistic ideal is that i could use classes "which i think i read that they are, basically a single block of info that you make, that you can duplicate and use kindof however you want" To make all the monsters in my text game "just to learn how to use the class function" and then just recal certain things from the class... But as you know,... thats an ideal and i still dont know exactly why you use classes "i think i might be totally off" but thats the path of learning. Thanks for the help ~SilverShalkin :rose: ps... this in win32 app con. "last forum asked me to specify what i was working in... there you go"

    C R 3 Replies Last reply
    0
    • S SilverShalkin

      Ok... Ive bean experimenting with classes "saying that i do not know anything (at all) about classes, its bean a confusing process" When i try to learn somthing I usually pinpoint the thing that i need to learn and start experimenting with it... "i do look through the MSDN a bunch and the help tutorial that VC++ 6.0 came with but if your unsuccesfull try the forums :)." My question is... to be responded by tutorial link or whatever... How do you use a class... why do you use them... What does Publuc do... What does private do... Do classes require any header files? Right now im doing somthing like: class monster; { //somthing here } my idealistic ideal is that i could use classes "which i think i read that they are, basically a single block of info that you make, that you can duplicate and use kindof however you want" To make all the monsters in my text game "just to learn how to use the class function" and then just recal certain things from the class... But as you know,... thats an ideal and i still dont know exactly why you use classes "i think i might be totally off" but thats the path of learning. Thanks for the help ~SilverShalkin :rose: ps... this in win32 app con. "last forum asked me to specify what i was working in... there you go"

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      SilverShalkin wrote: Ok... Ive bean experimenting with classes "saying that i do not know anything (at all) about classes, its bean a confusing process" I'm eating jelly beans right now - Harry Potter ones. :-) SilverShalkin wrote: How do you use a class... A class is an encapsulation of an idea. For example, a CString, a std::string, a std::vector, a CWnd are all classes, and they all encapsulate a concept. I'll pick on CString for the sake of the rest of this reply. CString is a collection of data members and functions that together give me a string as an object, and allow me to pass it around and operate on/with it. SilverShalkin wrote: why do you use them... One major thing C++ has over C is that C++ does not turn a project into a million functions all visible to one another. A class is used so that publically an interface is provided to do what the class is designed for, and the messy details are hidden and dealt with by the class. SilverShalkin wrote: What does Publuc do... It means when I go CString s; the function or variable in question can be called, for example, s.Format("%d", 6); SilverShalkin wrote: What does private do... It means I can't call/access the method/variable. Typically this means a function does something internal, and variables are generally private so they can be exposed through methods that filter what a person is trying to set a value to, if they are allowed to at all. SilverShalkin wrote: Do classes require any header files? A class consists of a header file, and optionally a cpp file ( because it can all go in the header ). If you're using precompiled headers ( and with VC you usually are ) then std.afx needs to be the first file included in the .cpp file, followed by the .h file. So if I have a class called MyClass, the first two lines in the .cpp file are likely to be #include "stdafx.h" #include "myclass.h" SilverShalkin wrote: my idealistic ideal is that i could use classes "which i think i read that they are, basically a single block of info that you make, that you can duplicate and use kindof however you want" If it's a representation of a block of data, you should use a struct. The only difference is that a struct has public members by default, a class has private, but a struct says to me a bl

      1 Reply Last reply
      0
      • S SilverShalkin

        Ok... Ive bean experimenting with classes "saying that i do not know anything (at all) about classes, its bean a confusing process" When i try to learn somthing I usually pinpoint the thing that i need to learn and start experimenting with it... "i do look through the MSDN a bunch and the help tutorial that VC++ 6.0 came with but if your unsuccesfull try the forums :)." My question is... to be responded by tutorial link or whatever... How do you use a class... why do you use them... What does Publuc do... What does private do... Do classes require any header files? Right now im doing somthing like: class monster; { //somthing here } my idealistic ideal is that i could use classes "which i think i read that they are, basically a single block of info that you make, that you can duplicate and use kindof however you want" To make all the monsters in my text game "just to learn how to use the class function" and then just recal certain things from the class... But as you know,... thats an ideal and i still dont know exactly why you use classes "i think i might be totally off" but thats the path of learning. Thanks for the help ~SilverShalkin :rose: ps... this in win32 app con. "last forum asked me to specify what i was working in... there you go"

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        Can I just say again that it scares the hell out of me that someone who doesn't know ( in this case ) what a class is, is talking about writing a game engine ? You're setting yourself up to fail, or in the least write something truly awful, when you set out to write something well and truly beyond your skills. You need to forget about windows, forget about games and sit down and learn these total basics which you lack. Write console programs until you understand C++ to the point of being able to write classes, a class structure that uses inheritance, and the standard iostreams and STL to at least a basic degree before you even think about windows or game programming. That is not to say you suck, it's more that like a lot of people, you're so eager to get the end result that you're not putting the time you need into the basics. I keep hoping for your sake that this particular light will come on, but the number of failed game engines in existance proves to me that this is not guarenteed to happen. Whatever happens, I'm always happy to answer your questions, but this is the best piece of advice you've got to date ( although I don't think it's the first time I have given it ). Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002

        J S 2 Replies Last reply
        0
        • S SilverShalkin

          Ok... Ive bean experimenting with classes "saying that i do not know anything (at all) about classes, its bean a confusing process" When i try to learn somthing I usually pinpoint the thing that i need to learn and start experimenting with it... "i do look through the MSDN a bunch and the help tutorial that VC++ 6.0 came with but if your unsuccesfull try the forums :)." My question is... to be responded by tutorial link or whatever... How do you use a class... why do you use them... What does Publuc do... What does private do... Do classes require any header files? Right now im doing somthing like: class monster; { //somthing here } my idealistic ideal is that i could use classes "which i think i read that they are, basically a single block of info that you make, that you can duplicate and use kindof however you want" To make all the monsters in my text game "just to learn how to use the class function" and then just recal certain things from the class... But as you know,... thats an ideal and i still dont know exactly why you use classes "i think i might be totally off" but thats the path of learning. Thanks for the help ~SilverShalkin :rose: ps... this in win32 app con. "last forum asked me to specify what i was working in... there you go"

          R Offline
          R Offline
          Ravi Bhavnani
          wrote on last edited by
          #4

          You should take a course in Object Oriented Analysis & Design (or at least read a book on the subject). This will give you the basics of OOP and will likely answer many of your current (and future!) questions. /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

          1 Reply Last reply
          0
          • C Christian Graus

            Can I just say again that it scares the hell out of me that someone who doesn't know ( in this case ) what a class is, is talking about writing a game engine ? You're setting yourself up to fail, or in the least write something truly awful, when you set out to write something well and truly beyond your skills. You need to forget about windows, forget about games and sit down and learn these total basics which you lack. Write console programs until you understand C++ to the point of being able to write classes, a class structure that uses inheritance, and the standard iostreams and STL to at least a basic degree before you even think about windows or game programming. That is not to say you suck, it's more that like a lot of people, you're so eager to get the end result that you're not putting the time you need into the basics. I keep hoping for your sake that this particular light will come on, but the number of failed game engines in existance proves to me that this is not guarenteed to happen. Whatever happens, I'm always happy to answer your questions, but this is the best piece of advice you've got to date ( although I don't think it's the first time I have given it ). Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002

            J Offline
            J Offline
            Jon Hulatt
            wrote on last edited by
            #5

            Christian Graus wrote: That is not to say you suck ROTFLMAO!!! Sorry to dissapoint you all with my lack of a witty or poignant signature.

            C 1 Reply Last reply
            0
            • J Jon Hulatt

              Christian Graus wrote: That is not to say you suck ROTFLMAO!!! Sorry to dissapoint you all with my lack of a witty or poignant signature.

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Well, I'm trying hard to get him to take the point - he is out of his league and should take the time to learn this stuff before thinking he can design and write a game engine. But it *is* kinda funny..... Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002

              J 1 Reply Last reply
              0
              • C Christian Graus

                Well, I'm trying hard to get him to take the point - he is out of his league and should take the time to learn this stuff before thinking he can design and write a game engine. But it *is* kinda funny..... Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002

                J Offline
                J Offline
                Jon Hulatt
                wrote on last edited by
                #7

                Oh... If you've got a couple of spare minutes, I'd love it if you could explain to me what a class is. Sorry to dissapoint you all with my lack of a witty or poignant signature.

                C 1 Reply Last reply
                0
                • J Jon Hulatt

                  Oh... If you've got a couple of spare minutes, I'd love it if you could explain to me what a class is. Sorry to dissapoint you all with my lack of a witty or poignant signature.

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #8

                  Jon Hulatt wrote: Oh... If you've got a couple of spare minutes, I'd love it if you could explain to me what a class is. Apparently something you should have attended more regularly if you went to Uni, otherwise something you should take up in the evening to help you understand how to program.... :laugh: :laugh: :laugh: :-D Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002

                  J 1 Reply Last reply
                  0
                  • C Christian Graus

                    Jon Hulatt wrote: Oh... If you've got a couple of spare minutes, I'd love it if you could explain to me what a class is. Apparently something you should have attended more regularly if you went to Uni, otherwise something you should take up in the evening to help you understand how to program.... :laugh: :laugh: :laugh: :-D Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002

                    J Offline
                    J Offline
                    Jon Hulatt
                    wrote on last edited by
                    #9

                    Wow. That helps. Now, tell me what is a pointer? how can i use them in my program? Sorry to dissapoint you all with my lack of a witty or poignant signature.

                    C 1 Reply Last reply
                    0
                    • J Jon Hulatt

                      Wow. That helps. Now, tell me what is a pointer? how can i use them in my program? Sorry to dissapoint you all with my lack of a witty or poignant signature.

                      C Offline
                      C Offline
                      Christian Graus
                      wrote on last edited by
                      #10

                      Jon Hulatt wrote: Wow. That helps. Now, tell me what is a pointer? how can i use them in my program? Here's a pointer - move to VB. :laugh: Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002

                      1 Reply Last reply
                      0
                      • C Christian Graus

                        Can I just say again that it scares the hell out of me that someone who doesn't know ( in this case ) what a class is, is talking about writing a game engine ? You're setting yourself up to fail, or in the least write something truly awful, when you set out to write something well and truly beyond your skills. You need to forget about windows, forget about games and sit down and learn these total basics which you lack. Write console programs until you understand C++ to the point of being able to write classes, a class structure that uses inheritance, and the standard iostreams and STL to at least a basic degree before you even think about windows or game programming. That is not to say you suck, it's more that like a lot of people, you're so eager to get the end result that you're not putting the time you need into the basics. I keep hoping for your sake that this particular light will come on, but the number of failed game engines in existance proves to me that this is not guarenteed to happen. Whatever happens, I'm always happy to answer your questions, but this is the best piece of advice you've got to date ( although I don't think it's the first time I have given it ). Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002

                        S Offline
                        S Offline
                        SilverShalkin
                        wrote on last edited by
                        #11

                        Christian Graus wrote: You need to forget about windows, forget about games and sit down and learn these total basics which you lack. Thanks... "Writting games is the only thing i know how to do... so weather it is a small stupid game... which ive bean doing "Stupid text(Just text)((Only only, text)" "no graphics what so ever..." (i think you get it) :) Im trying to learn the basics, thats why im working on text rpg instead of tetris clone. I want to know C++ to the fullest, so much that i can think of somthing to program and almost instintly think up the structure of that program. I am the most dedicated learner that "I" have ever seen. "I just dont know where to start." "I do know what a pointer is... kindof... it points to the address of somthing, you use "&" with it... I know of allot of things... but i dont know why they are used... or, what the can do to make my program run more efficiently. I need a project, somthing that i can do and learn the things i need to... so, till i find one, or till someone gives me one "learning purposes only" Im going to be cruising the books and taking note on whatever i can to program better. Thanks, "It scares the hell out of me to :)" ~SilverShalkin :rose:

                        C 1 Reply Last reply
                        0
                        • S SilverShalkin

                          Christian Graus wrote: You need to forget about windows, forget about games and sit down and learn these total basics which you lack. Thanks... "Writting games is the only thing i know how to do... so weather it is a small stupid game... which ive bean doing "Stupid text(Just text)((Only only, text)" "no graphics what so ever..." (i think you get it) :) Im trying to learn the basics, thats why im working on text rpg instead of tetris clone. I want to know C++ to the fullest, so much that i can think of somthing to program and almost instintly think up the structure of that program. I am the most dedicated learner that "I" have ever seen. "I just dont know where to start." "I do know what a pointer is... kindof... it points to the address of somthing, you use "&" with it... I know of allot of things... but i dont know why they are used... or, what the can do to make my program run more efficiently. I need a project, somthing that i can do and learn the things i need to... so, till i find one, or till someone gives me one "learning purposes only" Im going to be cruising the books and taking note on whatever i can to program better. Thanks, "It scares the hell out of me to :)" ~SilverShalkin :rose:

                          C Offline
                          C Offline
                          Christian Graus
                          wrote on last edited by
                          #12

                          SilverShalkin wrote: Writting games is the only thing i know how to do Bull. You mean 'writing games is all I want to do'. Game programming is a superset of common programming skills. If you cannot write a calculator ( my suggested first C++ task ) then you cannot write a game. Period. SilverShalkin wrote: Im trying to learn the basics, thats why im working on text rpg instead of tetris clone. An rpg is *not* the basics. This is what I'm trying to get you to understand. SilverShalkin wrote: I want to know C++ to the fullest, so much that i can think of somthing to program and almost instintly think up the structure of that program. *grin* if you manage that you'll be beating everyone here, but I understand what you mean. Do you own 'the C++ programming language' by Bjarne Stroustrup ? You should get it if you don't. SilverShalkin wrote: I am the most dedicated learner that "I" have ever seen. "I just dont know where to start." Write a calculator program. Make a base class called calculation that defines what a calculation does, then define derived classes that do individual calculations such as add. No program would ever do this for a calculator, but the simplicity of the task will let you focus on the details required to make the classes behave properly. Then have a pointer to the base class in your main app, so you can learn more about pointers and so on. Use dynamic_cast to find out if the pointer you have is the type you want or not. Again, this example is designed to teach you a lot of stuff, not to be practical. I'd be glad to help you. SilverShalkin wrote: I know of allot of things... but i dont know why they are used... or, what the can do to make my program run more efficiently. Which gets back to me saying focus on the basics for a bit. SilverShalkin wrote: so, till i find one, or till someone gives me one "learning purposes only" Im going to be cruising the books and taking note on whatever i can to program better. Stroustrups book is also full of examples and exercises. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer

                          S 1 Reply Last reply
                          0
                          • C Christian Graus

                            SilverShalkin wrote: Writting games is the only thing i know how to do Bull. You mean 'writing games is all I want to do'. Game programming is a superset of common programming skills. If you cannot write a calculator ( my suggested first C++ task ) then you cannot write a game. Period. SilverShalkin wrote: Im trying to learn the basics, thats why im working on text rpg instead of tetris clone. An rpg is *not* the basics. This is what I'm trying to get you to understand. SilverShalkin wrote: I want to know C++ to the fullest, so much that i can think of somthing to program and almost instintly think up the structure of that program. *grin* if you manage that you'll be beating everyone here, but I understand what you mean. Do you own 'the C++ programming language' by Bjarne Stroustrup ? You should get it if you don't. SilverShalkin wrote: I am the most dedicated learner that "I" have ever seen. "I just dont know where to start." Write a calculator program. Make a base class called calculation that defines what a calculation does, then define derived classes that do individual calculations such as add. No program would ever do this for a calculator, but the simplicity of the task will let you focus on the details required to make the classes behave properly. Then have a pointer to the base class in your main app, so you can learn more about pointers and so on. Use dynamic_cast to find out if the pointer you have is the type you want or not. Again, this example is designed to teach you a lot of stuff, not to be practical. I'd be glad to help you. SilverShalkin wrote: I know of allot of things... but i dont know why they are used... or, what the can do to make my program run more efficiently. Which gets back to me saying focus on the basics for a bit. SilverShalkin wrote: so, till i find one, or till someone gives me one "learning purposes only" Im going to be cruising the books and taking note on whatever i can to program better. Stroustrups book is also full of examples and exercises. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer

                            S Offline
                            S Offline
                            SilverShalkin
                            wrote on last edited by
                            #13

                            Christian Graus wrote: SilverShalkin wrote: Writting games is the only thing i know how to do Bull. You mean 'writing games is all I want to do' "its all that i have the heart to program" (learning quickly though, calculater program may help more :)) Christian Graus wrote: Do you own 'the C++ programming language' by Bjarne Stroustrup ? You should get it if you don't. this is a book right? or is it the actual programming language? "just wondering" ill go and check it out. thanks for the help ~SilverShalkin :rose:

                            C 1 Reply Last reply
                            0
                            • S SilverShalkin

                              Christian Graus wrote: SilverShalkin wrote: Writting games is the only thing i know how to do Bull. You mean 'writing games is all I want to do' "its all that i have the heart to program" (learning quickly though, calculater program may help more :)) Christian Graus wrote: Do you own 'the C++ programming language' by Bjarne Stroustrup ? You should get it if you don't. this is a book right? or is it the actual programming language? "just wondering" ill go and check it out. thanks for the help ~SilverShalkin :rose:

                              C Offline
                              C Offline
                              Christian Graus
                              wrote on last edited by
                              #14

                              SilverShalkin wrote: "its all that i have the heart to program" (learning quickly though, calculater program may help more ) Exactly. The point is not to love what you're doing, but to do things that will equip you to do what you love. SilverShalkin wrote: this is a book right? or is it the actual programming language? "just wondering" ill go and check it out. It's a book - get the third edition, which is the current one. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002

                              L 1 Reply Last reply
                              0
                              • C Christian Graus

                                SilverShalkin wrote: "its all that i have the heart to program" (learning quickly though, calculater program may help more ) Exactly. The point is not to love what you're doing, but to do things that will equip you to do what you love. SilverShalkin wrote: this is a book right? or is it the actual programming language? "just wondering" ill go and check it out. It's a book - get the third edition, which is the current one. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002

                                L Offline
                                L Offline
                                Lost User
                                wrote on last edited by
                                #15

                                Christian, I am not sure if you are aware but a text RPG is actually a console program not windows, usually in a text rpg they will give you a story then ask you a question and you reply by typing "turn east" or another sort of function.:cool:

                                B 1 Reply Last reply
                                0
                                • L Lost User

                                  Christian, I am not sure if you are aware but a text RPG is actually a console program not windows, usually in a text rpg they will give you a story then ask you a question and you reply by typing "turn east" or another sort of function.:cool:

                                  B Offline
                                  B Offline
                                  Brian Olej
                                  wrote on last edited by
                                  #16

                                  Whoops just to let you know that was me... i thought was logged in:-O

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups