Confused about C++

Started by
16 comments, last by Aardvajk 12 years, 10 months ago
I've been wanting to learn C++ for awhile now, I recently finished an object-oriented programming class and did fairly well there. So today I decided I'm going to start learning C++ in my spare time between my other classes. So I cracked open my C++ for Dummies book I've had lying around and went through the steps of setting up Dev-C++ on my machine and started reading through the book. The books says that everything in the book is command line based. This is where I am confused, I know that C++ is used for many applications and most games, but am I missing something? How can I learn to create games if everything is command line based. I did a quick search here and couldn't find my answer.
Advertisement
It probably means that the applications the book teaches you are only command line based. You can create any kind of app you want with c++. What language did you use in the class? Depending on what kinds of games/applications you want to make, there all almost infinite possibilities for how to make a non command line program
C++ doesn't have graphics, sound and such things build in. You will need to use some non-standard libraries for that. There is a lot of them so this is not really a problem.

It probably means that the applications the book teaches you are only command line based. You can create any kind of app you want with c++. What language did you use in the class? Depending on what kinds of games/applications you want to make, there all almost infinite possibilities for how to make a non command line program


My class used Java. But it was the same thing, all command line. I guess if the book will teach me the required information to learn what is needed to create games then I will stick with it.
It's normally agreed that it is best to learn the basics of the language in a text-mode console so you can focus on them without the additional complexities then move on to something graphically based when you feel more confident with your C++. Most graphics libraries will require a certain level of C++ knowledge to use them effectively.

Once you are ready, and if you are determined to stick with C++ over something like C# and XNA, I hear good things about SFML as a library for handling graphics, sound etc.

I've been wanting to learn C++ for awhile now, I recently finished an object-oriented programming class and did fairly well there. So today I decided I'm going to start learning C++ in my spare time between my other classes. So I cracked open my C++ for Dummies book I've had lying around and went through the steps of setting up Dev-C++ on my machine and started reading through the book. The books says that everything in the book is command line based. This is where I am confused, I know that C++ is used for many applications and most games, but am I missing something? How can I learn to create games if everything is command line based. I did a quick search here and couldn't find my answer.


Basically everything your game does that affects any hardware(such as the graphicscard) besides the cpu and ram is platform dependant, if you're using a realmode OS (such as DOS) you can get graphics by writing directly to the graphics card, for modern operating systems (Windows/Linux/etc) direct hardware access is restricted to drivers and you have to use the APIs provided by the OS and/or drivers in order to access the hardware. (Even access to the keyboard is restricted so C++ can only access the standard input (Which may or may not get its data from the keyboard just like the standard output may or may not be printed into a console window) (Full keyboard access is obtained through the OS just like access to any other piece of hardware)

For Windows this means that you have to use Win32 to talk to the OS and Direct3D / OpenGL / Direct2D or GDI for graphics. You can also use a higher level API that sits on top of the APIs your OS supports directly (Many such high level APIs will allow you to use the same code on multiple platforms and are in general far better than the OS specific APIs they use under the hood). (Both Win32 and X11 are awful APIs so for games something like SDL or SFML are far better options)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

I've been wanting to learn C++ for awhile now, I recently finished an object-oriented programming class and did fairly well there. So today I decided I'm going to start learning C++ in my spare time between my other classes. So I cracked open my C++ for Dummies book I've had lying around and went through the steps of setting up Dev-C++ on my machine and started reading through the book. The books says that everything in the book is command line based. This is where I am confused, I know that C++ is used for many applications and most games, but am I missing something? How can I learn to create games if everything is command line based. I did a quick search here and couldn't find my answer.


Some will argue how I've phrased some of this, but for someone new to all of this it might give you just enough detail to help you realize where a lot of subtle lines are drawn, conceptually.

Everything is command-line based in beginner material because using OpenGL and other API's goes above and beyond the language itself. C++ is a programming language, like english is a language, can you write poetry, novels, comics, or any kind of literary arts if you don't understand the language? Art and science are not a part of a language, but are communicated about through a language.

That analogy might not seem to make sense at first, but consider this; a graphics card and its feature sets have nothing to do with any specific language. Just about all languages have third party libraries which allow you to execute instructions on devices connected to your computer.

Beginners and experts alike are always writing console applications for various reasons, for the most part even experts will still write basic command line software to test and study logical components that will fit in to a larger piece of software at some point. This is where what I'm telling you might start coming together.

C++ is a language, and command line applications are the simplest type of programs, they require the least amount of work and logical artifacts to get going. For that reason alone it is the ideal starting point for learning the language. Only after you understand how to translate your ideas in to logic|math and then implement through computer programming does it make sense to understand how a language itself is extended through libraries and go even further.

The important thing to learn is how to represent abstract thought in the form of logical statements (maths), once your thoughts are stated logically you can express your thoughts through any programming language. Most people don't realize what they have trouble with is not computer programming, but expressing abstract thoughts, conceptual information, as logical phrases. That is the reason why mathematics is so important in computer programming, and even more important in game programming. Game theory material can show you how to think about game rules and outcomes in a very abstract way, and in beginner material usually taught within the context of something like a tic tac toe game just so that you can begin to see why it matters. When you see how thinking like that ties in to computer programming you'll intuitively understand why mathematics is actually so important to the human race. But now I'm just getting carried away.

C++ in itself has surprisingly few features, without at least the C++ standard libraries you would wonder what the point of C++ even is (naively).

OpenGL and DirectX are standards which motivate the design of respective API's (Application Programming Interface) which programmers map to a given language through libraries. Generally speaking libraries help to extend (in a more convenient way) a language with the ability to do more than it is designed to. Graphics card makers actually build in hardware functionality based on OpenGL|DirectX standards, it's there from the ground up which is why you'll see those two always spoken about where ever graphics programming is spoken about.

In short and i.e.; The C++ OpenGL libraries are an API for C++ to graphics cards which support OpenGL.

What you need to understand above all are these distinctions, in explicit and clear detail, between the nature of a games, graphics, logic, math and C++ as a language.

C++ is strictly on of many syntax of the computer language, it is how you 'speak' computer, it's through that language that you intricately tie together the necessary logic and math to guide graphic visualizations and game rules, or what ever it is you want to accomplish.

You might want to re-read that a few times and don't worry; you'll adapt to the terminology the more you read it. Learning is a physical thing, repetition is learning because your brain has to physically embed all this mess in to your brain matter. So don't give up if you feel exhausted, just take a break and come back, re-read and re-learn over and over until it 'feels natural'. I've been doing this stuff for more than a decade, and I'm still learning, I love graphics and audio programming, and you will only get good at this if you simply keep at it for ever. Always work on and complete one project at a time, and always step up the notch in complexity so you are forced to learn new things, one step at a time.

What you should be doing right now through C++ is learning about basic data types, class design (OOP) through C++, feel comfortable with the syntax, learn about managing memory in your programs, learn the plumbing of computer programs and the fundamentals.

From there you have a foundation to stand on, where you can begin building a house, which has it's own challenges apart from building a stable foundation! To construct something composed of many pieces requires understanding many pieces separately, and then how they fit together.

Sorry if this is a lot, I probably got carried away, an OCD thing.
Thanks for the information guys, I just didn't want to waste time on something if it wasn't the right thing I needed. I am going through the book now and mostly its pretty much the same as my Java class, so I'm able to breeze through a lot of the material.
Any recommendations on where I go from there? Browsing through my book its pretty much loops, arrays, inheritence and so forth. I already know the basics of this but once I feel comfortable with them is there a book or tutorial that will take me to the next step? Once I get through expressions and operations I want to start learning about programming actual apps from Windows, so where do I go from here?
> I want to start learning about programming actual apps from Windows, so where do I go from here?

Choose a particular direction. If you want to make a GUI, you need to pick a GUI toolkit. In Windows, there's the Windows API itself, and there are various other toolkits like GTK+, Qt, FLTK, etc.

If you want to render something to screen, at the most basic level, you have GDI+ from Windows, OpenGL, Direct3D, but you'll probably want to get something like SFML, SDL, or some other library to create the window and context before you draw to the screen.

Of course, if you can't actually write any non trivial programs by yourself, then you won't have any idea what you're doing when you pick up one of those libraries.

Once I get through expressions and operations I want to start learning about programming actual apps from Windows, so where do I go from here?



I'd say download visual studio 2010 express (it's free) and create a windows form application.
Then to get you started:
1. open the toolbox (in view, in case you dont see it yet)
2. drag a button to the form
3. double click the button.
This will take you to the "on button click" event and it generated a function for you.
Then you can type Form1. and it'll show you all the things you can do.
Probably Form1.Text = "Hello World"; (or similar) will do something.

Then it's just a question of knowing the objects you can put in the form, and getting deeper in the language itself and creating classes and stuff.

This topic is closed to new replies.

Advertisement