Sign in to follow this  
JimmyLeeMullins

Confused about C++

Recommended Posts

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.

Share this post


Link to post
Share on other sites
zacaj    667
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

Share this post


Link to post
Share on other sites
Wooh    1088
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.

Share this post


Link to post
Share on other sites
[quote name='zacaj' timestamp='1306017169' post='4813994']
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
[/quote]

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.

Share this post


Link to post
Share on other sites
Aardvajk    13207
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 [url="http://www.sfml-dev.org/"]SFML[/url] as a library for handling graphics, sound etc.

Share this post


Link to post
Share on other sites
SimonForsman    7642
[quote name='JimmyFett' timestamp='1306016723' post='4813990']
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.
[/quote]

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)

Share this post


Link to post
Share on other sites
gltiich    128
[quote name='JimmyFett' timestamp='1306016723' post='4813990']
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.
[/quote]

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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
oler1s    585
> 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.

Share this post


Link to post
Share on other sites
stromchin    102
[quote name='JimmyFett' timestamp='1306100551' post='4814359']
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?
[/quote]


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.

Share this post


Link to post
Share on other sites
ryan20fun    2635
[quote name='JimmyFett' timestamp='1306016723' post='4813990']
The books says that everything in the book is command line based.
[/quote]

what i think it means and from what i know is this(from Visual Studio experiance):
and IDE like Visual Studio which [i]stromchin[/i] so kindly mentioned and Dev-C++ are a way of Graphically editing it (as opposed to writeing code in a standard text editor) (and i vouch for Visual Studio as it is very good in my opinion)

but it is still compiled through the 'Command Line', IE VS can do error checking, Syntax and so on but it uses the 'Command Line' to tell MSBUILD to compile your app with all relevent data and such (i may be a bit off here but as far as i know this is correct) and then VS attaches its debugger to your exe.
does that help ?

Share this post


Link to post
Share on other sites
[quote name='ryan20fun' timestamp='1306143383' post='4814521']
[quote name='JimmyFett' timestamp='1306016723' post='4813990']
The books says that everything in the book is command line based.
[/quote]

what i think it means and from what i know is this(from Visual Studio experiance):
and IDE like Visual Studio which [i]stromchin[/i] so kindly mentioned and Dev-C++ are a way of Graphically editing it (as opposed to writeing code in a standard text editor) (and i vouch for Visual Studio as it is very good in my opinion)

but it is still compiled through the 'Command Line', IE VS can do error checking, Syntax and so on but it uses the 'Command Line' to tell MSBUILD to compile your app with all relevent data and such (i may be a bit off here but as far as i know this is correct) and then VS attaches its debugger to your exe.
does that help ?
[/quote]

It does help, I'm going to try to get myself a copy of Visual Studio soon to start playing around with.

Share this post


Link to post
Share on other sites
FelixK15    335
[quote name='JimmyFett' timestamp='1306149940' post='4814539']
It does help, I'm going to try to get myself a copy of Visual Studio soon to start playing around with.
[/quote]

You should really do that. Dev C++ is unsupported since ~4-5 years.

Share this post


Link to post
Share on other sites
ryan20fun    2635
[quote name='FelixK15' timestamp='1306150802' post='4814545']
[quote name='JimmyFett' timestamp='1306149940' post='4814539']
It does help, I'm going to try to get myself a copy of Visual Studio soon to start playing around with.
[/quote]

You should really do that. Dev C++ is unsupported since ~4-5 years.
[/quote]

yes, but there is a new one called wxDev-C++ (i think)
just wanted to point that out :)

Share this post


Link to post
Share on other sites
Kalten    189
If you're a student look into the dreamspark program by microsoft, you might be able to get VS2010 for free.

[url="http://www.dreamspark.com"]www.dreamspark.com[/url]

Share this post


Link to post
Share on other sites
FelixK15    335
[quote name='ryan20fun' timestamp='1306157013' post='4814575']


yes, but there is a new one called wxDev-C++ (i think)
just wanted to point that out :)
[/quote]

Oh cool. I didn't know that. Thanks for the info.
Well anyway...Since I'm working with VS 2010 I'm perfectly happy ;)

Share this post


Link to post
Share on other sites
exoity    208
For more information on why not to use Dev-C++, check out http://www.jasonbadams.net/20081218/why-you-shouldnt-use-dev-c/

I would also highly recommend using Visual Studio 2010 Express

Share this post


Link to post
Share on other sites
Aardvajk    13207
If you are going down the Visual Studio Express route for Windows programming, I'd highly also recommend the free [url="http://www.resedit.net/"]ResEdit[/url] which you can integrate into VS quite nicely.

I'm jumping ahead a bit here, but VS Express lacks the visual resource editor that the paid-for versions have and when it comes to dealing with resources, especially the layout of dialog boxes, you do NOT want to be doing that with a text editor. Well, not unless you enjoy it taking four hours to get a button in the right place anyway. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this