Jump to content
  • Advertisement

BcS

Member
  • Content Count

    43
  • Joined

  • Last visited

Community Reputation

122 Neutral

About BcS

  • Rank
    Member
  1. Thanks for the replies. You guys are fast :) I do realize that the code will compile without including x.h in myclass.cpp (because myclass.h include x.h and I include myclass.h in myclass.cpp), but I want to make sure I'm doing things correctly. I thought I might have to include x.h in my myclass.cpp so that the .cpp can stand on its own. Take scenario #3, for example. In the myclass.cpp file, I declare a variable of type X and I can only do that because myclass.h includes x.h. But if myclass.h is ever changed so as to not include x.h, myclass.cpp won't compile. So, shouldn't I include x.h in myclass.cpp to avoid this ever being a problem? Thanks again, --Bob
  2. Let's say I have a class, MyClass, broken up into a header file (myclass.h) and an implementation file (myclass.cpp). I'm unsure what to include in the myclass.cpp under several different scenarios: 1) The myclass.h file declares a member variable of type X and I include a header file for that type. In the myclass.cpp file, I never directly use the name of type X, but I do call member functions of the member variable of type X that was declared in myclass.h. So, in the myclass.cpp file, do I need to include the header file for type X? Here's a short example to make it clear: myclass.h #include "x.h" class MyClass { public: void UseMyVar(); private: X myVar; }; myclass.cpp #include "myclass.h" void MyClass::UseMyVar() { myVar.DoSomething(); } The code does compile, but should I include "X.h" in myclass.cpp since I call a member function of an X object, myVar? 2) The myclass.h file declares a member variable of type X and I include a header file for that type. In addition, I use X as a type for a parameter in a member function. (As a result, type X will appear in both the .h and the .cpp file) So, in the myclass.cpp file, do I need to include the header file for type X? Here's a short example to make it clear: myclass.h #include "x.h" class MyClass { public: void MyMemberFunc(X aVar); }; myclass.cpp #include "myclass.h" void MyClass::MyMemberFunc(X aVar) {} The code does compile, but should I include "X.h" in myclass.cpp since I use it as a type for a parameter here? 3) The myclass.h file declares a member variable of type X and I include a header file for that type. In the .cpp file, the only place I use X is to declare a local variable. So, in the myclass.cpp file, do I need to include the header file for type X? Here's a short example to make it clear: myclass.h #include "x.h" class MyClass { public: void MyMemberFunc(); private: X myVar; }; myclass.cpp #include "myclass.h" void MyClass::MyMemberFunc() { X aVar; } The code does compile, but should I include "X.h" in myclass.cpp since I'm declare a variable of type X in it? Thanks for helping me understand the correct way to include files! --Bob
  3. BcS

    is this a good book

    "Beginning C++ Game Programming" is a great book to start with. It assumes no previous programming experience. It teaches the fundamental of C++ through text-based games only. That's right, no graphics -- which is exactly what you want in the beginning. It takes you from displaying text in a console window up to classes and inheritance, all the while making simple games (like hangman or blackjack). It's gotten great reviews here and on amazon. Definitely worth a look.
  4. Python meets at least three of your requirments: * maximum flexibility as to platforms, e.g. PC, Mac, Internet hosted; * easy to comprehend; * quickly obtain working, impressive game(s), capturing the youngsters attention, stimulating them to learn more; I think it also meets your other requirment that it runs on the net, but I've never used it for that personally. Check out Python Programming for the Absolute Beginner. By the end of the book, you make an asteriods clone. Also, here's a paper written by teachers at a school that decided to teach Python and their results.
  5. BcS

    a fun python book for beginners?

    Very fun. Great reviews. And you make games with graphics. Plus, same author of the well-reviewed Beginning C++ Game Programming. Python Programming for the Absolute Beginner
  6. BcS

    Game design in python?

    Also check out this book. Teaches game programming through Python. By the end you made as asteriods clone.
  7. BcS

    c++ learning

    Yes. The book actually comes with Dev-C++ on the CD. It was the book expects you to use. So should be good for you.
  8. BcS

    c++ learning

    Beginning C++ Game Programming - is perfect. An excellent beginner C++ book that teaches text-based games along the way. Also reviwed here on gamedev. Once you get beyond the basics, I'd recommend Thinking in C++.
  9. A book that's gotten good reviews right here on gamedev is Beginning C++ Game Programming. Teaches C++ in context of making games. Cheap too - about twenty bucks on amazon.
  10. BcS

    Books, where to start??

    A really good first C++ book (espc. for game programmers) is "Beginning C++ Game Programming." It teach you both about C++ and game programming (beginning). Also, very fun book to go through - no boring programs (all games). Check it out.
  11. BcS

    C++

    If you want to learn C++ to program games, then I recommend "Beginning C++ Game Programming". It teaches you the basics of C++ while you program simple, text-based games. It shows you how C++ is relevant to games and will keep you interested along the way. The book also does introduce the STL. No doubt that "Primer" is more comprehensive, but it also costs twice as much. Also, the book is a bit dry and not related to games. I'd would only recommend "Primer" over "Beginning" if your sole goal was to learn C++ (and not game programming). After reading "Beginning" and getting the basics down in an entertaining way, you can move on to an advanced book/tutorials.
  12. BcS

    Learn C++ with games in mind?

    Quote:Original post by GroZZleR Quote:Original post by daviangel if(false) if(true) cout << "This will never be displayed."; else cout << "This will always be displayed."; Saying "This will always be displayed" is rather misleading, as thats not true. Nothing will be displayed. The else belongs to the nested if, not the parent if. Atleast, from my understanding. Yes, this is exactly what the author says - nothing will print out. (I have a copy of the book too). The author uses the code to point out a beginners' pitfall. (That an else is associated with its nearest preceding if, regardless of whitespace)
  13. I add my vote for Python. Powerful and easy to learn -- plus it's the perfect steppingstone to C++. Check out Python Programming for the Absolute Beginner, it not only teaches Python but does so by using games as examples. Just what the OP was looking for, methinks.
  14. BcS

    Good C++ Books

    ugoff, yeah, Beginning C++ Game Programming looks just like what you're looking for -- teaches C++ and game programming to beginners. A thread on this forum has someone that has the book and gives it a good review.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!