Jump to content
  • Advertisement
Sign in to follow this  

OOP help

This topic is 5044 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm kind of new to Gamedev. I've been browsing for more than a year now but have never really asked/replied to anything(I'm one of those quiet, shy guys), so here goes my first attempt. I've been programming in C++ for a little over a year and a half now and I think that I have grasped the basic syntax of it. My problem is that I don't feel like I have quite the grasp of OOP, if any at all. When I go to write a program, I can see how it could be done, the problem is just implementing it. It's like a puzzle: I can see how the pieces are, but I can't put them together. It seems like the only way to make my code work would be to create numerous global variables and work them into m code. The problem with that is it will create spaghetti code quickly, which I don't want. When I see other people's code I can see how the different classes work together and form a whole, it is just when I try it doesn't come together so nicely. Can you see my problem? So what I'm asking is for some pointers on get through this road block. Are there any good books out there that talk about OOP? Any personal experieces with this? Any links to places that talk about OOP? Thanks for any help! Tom

Share this post

Link to post
Share on other sites
I would be willing to answer any questions you have on OOP.



whatnewdevilryisthis@hotmail.com on Messenger (nick is BalRog).


I am in the middle of developing a Windows 2D board game in C# (very close in syntax to C++) and I have some experience in OOP. The fellow who is helping me write the game knows even more than I do...so we've got you covered.

Share this post

Link to post
Share on other sites
Something that may interest you is UML.

It's a description language that helps you structure your programs and various aspects of larg projects.

Most modern UML IDE will produce simple class code for you so all u have to do is drag and drop.

I'm pretty new to this stuff so can't really point u too any resources, but search google.


Share this post

Link to post
Share on other sites
There are of course TONS of books, websites, tutorials, etc. on C++ and OOP. The question really is...every person is different and learns in a different way. What is the best way for you to get over your C++ / OOP roadblocks? How do you learn best?

Just run a google search or go to http://www.amazon.com and search for C++. I did this and I got back approx 2000 listings!!!! Here are a few that caught my eye:

C++ for Dummies

I have a slightly older version of this book...and it is excellent.




C++ How to Program

The Deitel books are very good and give complete coverage of C++ with tons of examples. I had a few Deitel books while getting my degree in IT.

I have found game programming to be an excellent way to learn OOP or just to learn programming in general. The reason is...if you are working on a game that interests you...there is intrinsic value to the activity...and you are less likely to lose interest. The motivation is there because you are learning the OOP in order to get to what you REALLY want....a working game. :) Make sense?

One website in particular that has been a tremendous help to me is:


For $10 a month....you can ask unlimited questions on almost any topic under the IT umbrella...including C++. Some of the best C++ programmers in the world frequent this site...and they compete to answer your questions thoroughly!! I've been a member for over 4 years now. It is excellent. Even if you join for a month or two (the cost of a tank of gas)...you'll be convinced this is one of the best resources around.

Share this post

Link to post
Share on other sites
Hi Tom. Yes, I know exactly what you mean. I have a few techniques that helped me in the beginning. First, when you find it is hard to come up with a way to implement or design a class hierarchy, you could try getting out a piece of paper and brainstorm all of the ideas and concepts you want to include into your program and write them in a list format. Say you're making a RPG type game. Here is an example of a way you could do this:

I'd then take this list and start making classes out of them. The key point is to understand that you need to make it as general as possible, and then using inheritance for more specific and related topics. For example, combat is an important feature in an RPG; you can use inheritance for attack/defense. When I first started I used to use global variables all the time. It looked very messy with all these identifiers all jumbled up in one place, so then I discovered classes :).

I've heard some good things about the book "Object Oriented Programming in C++," though I have not read it. You may also want to check out this link: http://www.rit.edu/~jpw9607/ooptut/part1.htm#Thinking%20in%20OOP.
If you have any questions, please post them. I'd love to help you out! Good luck!

btw, email if any questions: mindstorm111@sbcglobal.net

Share this post

Link to post
Share on other sites
I have looked at Amazon for books, but by browsing through it just seems most of those C++ books are like the one I already have(Sams Teach Yourself C++ in 21 Days). I have looked at Object Oriented Programming in C++ and it seems to be just like any other beginning book, with the name stating that it also teaches OOP. Thanks for the suggestion though.

I have heard of UML, but have never used it before. In my opinion it would be better used for larger projects where you have many classes doing different functions (such as classes acting as objects, object factories, class wrappers, etc).

I guess my real problem is applying it, not the actual implementation of it(Do you understand that?). I know about the concepts of OOP, it's just putting it all together and making it function as a whole.

Thanks for the suggestion. I have tried that before, it's just when I think I've got them all, I run into an error when I try to code them.

Thanks for all of the support so far.


PS - Anyone here read Modern C++ Design? I tempted to get, but I don't know if would help me right now.

Share this post

Link to post
Share on other sites
The best thing to do, in my opinion, is to download some open source code, and read it. Build it. Step through it in a debugger. Understand it. Then try to make some change; implement it, and test it. If it doesn't work, try again until it does.

Really, reading other people's code is absolutely the best way of learning how you can do different things. Preferrably, a lot of different code, because different people do things differently.

These days, this is easy, because there are SO many open source projects to choose from. Just pick one that's small, and start there.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!