I'm lost in C++, please help !

1e9182fb7b2ffa9112b2fd9efb99148e
0
snikes 101 Dec 28, 2005 at 09:11

Okay,

I must admit that it is much harder than I would have thought. I’m coding for a long time with several languages (Java, Perl, Php) and I was thinking that C++ wouldn’t be such a big deal.

It is not that I don’t know how to code in C++, what bothers me is the libraries. I mean, with Perl (CPAN), PhP or the Java API, I have a set of standard classes/libraries that saves me a lot of time managing data streams, I/O, arrays, strings processing… With C++ it’s like starting from scratch, I know that there are hundreds of C++ libraries out there but I just don’t know what do I need and which one should I use.

That’s like compiler and linker settings, pragmas, symbols… these are just chinese to me. I found a tutorial for just creating a window, it took 2 pages long and for most of the code, I don’t know why it is here.

When I see myself stuck with such a newb problem, I start thinking to myself that building my own little game (even just a pacman :lol: ) is out of reach.

I bought a couple of books but most of the time they rely heavily on VC++ and MFC when I’m more interested in using standard libraries (I would like my programs to work on both Win and Linux).

Do you guys know any site proposing good tutorials for C++, I’m not even thinking about coding with Ogre, just basic tutorials for creating windows, configuring your compile and linker flags and symbols, dealing with windows events….:surrender

21 Replies

Please log in or register to post a reply.

6aa952514ff4e5439df1e9e6d337b864
0
roel 101 Dec 28, 2005 at 09:43

Do you guys know any site proposing good tutorials for C++, I’m not even thinking about coding with Ogre, just basic tutorials for creating windows, configuring your compile and linker flags and symbols, dealing with windows events….

Maybe you should take an other path: first master (a bit of) the language itself, then go for things like compiler/linker flags, windows and events. The latter two aren’t even native C++ things, they are just systems that can be used with C++. The console screen is enough for mastering the language, imo.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Dec 28, 2005 at 09:54

I would pick up a copy of The C++ Programming Language by Bjarne Stroustrup. This will give you a reference to the language, and a little bit about the standard libraries. The C++ Standard Library by Nicolai Josuttis will go into more depth with those libraries, which are very useful. Amazon has a nice discount for buying these two books together. Alternatively, C++ In a Nutshell is a more succinct (and cheaper) introduction to the language and its libraries.

For information on setting up compiling options, you’ll have to consult the docs for your specific compiler. If you are using Visual Studio, most of the options are fine left at their defaults. You just create a project, type in your code and click build.

I would recommend, so long as you’re a beginner with the language, to stay away from windowing systems and just write console programs. When you’re ready, if you’re using Windows, then Petzold’s Programming Windows is the classic reference that you can consult when you have a solid grasp of C++ (which shouldn’t take long given your experience in Java). Also, learning C# (which is a Java-like language) and Windows Forms is probably a better way to develop serious Windows apps, as doing anything more complicated than a window with a menu bar and some dialog boxes gets rather hairy in C++. However if you’re looking to do games then C++ is more likely to be the right language (though C# has also been used for games).

1e9182fb7b2ffa9112b2fd9efb99148e
0
snikes 101 Dec 28, 2005 at 09:57

I know the C++ language because I used it a bit (I’ve done a console library many years ago, but that didn’t involved any library just basic console I/O methods) and languages like Java and PhP rely heavily on the C language structure.

My problems begins with flags and, as you said, what is not native C++ things.

Everytime I find tutorials about C++, it seems like the authors consider that the reader already masters compiler/linker flags and widely used libraries.

1e9182fb7b2ffa9112b2fd9efb99148e
0
snikes 101 Dec 28, 2005 at 09:59

@Reedbeta

I would pick up a copy of

Thank you Reedbeta, I’m already browsing Amazon’s site looking for the books you told me. :yes:

F1c9c75e541af39cb5e9680a39d5f220
0
damn 101 Dec 28, 2005 at 17:54

When i started programming, i went streight to using and learning C++, and found myself understanding very little for a while…

The trick is, you just need to know where to find the best tutorials on the net for programming with C++.

You said something about creating a window takes 2 pages of code or something… soz, im too lazy to quote… Its not all true… C++ has many more advantages than disadvantages, and hundreds of ways to programme one thing, like a window for instance… Ive seen a window programmed in +/- a half a page and many might have seen even less lines used. I think one might say that it depends on the technique you use?! :blink:

www.gametutorials.com
nehe.gamedev.net
www.cprogramming.com

and googlegooglegoogle!!!
:D

Good Luck!

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Dec 28, 2005 at 18:55

It is not that I don’t know how to code in C++, what bothers me is the libraries. I mean, with Perl (CPAN), PhP or the Java API, I have a set of standard classes/libraries that saves me a lot of time managing data streams, I/O, arrays, strings processing… With C++ it’s like starting from scratch, I know that there are hundreds of C++ libraries out there but I just don’t know what do I need and which one should I use.

http://www.boost.org/

that library will provide a lot of the functionality you are looking for.

22b3033832c5c699c856814b0cf80cb1
0
bladder 101 Dec 29, 2005 at 06:37

yep, boost is the “bigun” in the c++ world, boost and the stl (which comes with you standard library). It’s mostly the libraries from boost nowadays that get considered for being put right into the c++ standard right?

Cd577ee1cb56aa2ad5645b7daa0a2830
0
eddie 101 Dec 29, 2005 at 07:07

If you mean TR1, then yes.

See Scott Meyer’s TR1 Information page.

1e9182fb7b2ffa9112b2fd9efb99148e
0
snikes 101 Dec 29, 2005 at 08:10

Thanks for all your replies.

Btw, while browsing the Amazon site for the “Programming Windows” book I found a customer comment, a guy programming on window since 97, who pretends that Microsoft is willing to push VC++ on the .NET plateform and that in a close future every single C++ code pretending to run on windows will have to rely on .NET.

What do you think of this comment ? If true, if your aim is to create game, will you have to use .NET ?

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Dec 29, 2005 at 09:07

Microsoft is certainly pushing .NET hard. However, Windows operating systems will be able to run “native” C++ code for a very long time yet. And actually, C++.NET has already been deprecated (MS are no longer supporting it). They recommend using C# or Visual Basic to develop .NET applications.

Developing games using .NET is likely to be rather awkward for the near future, however. Interfacing with Direct3D or OpenGL requires writing “unmanaged” code, effectively non-.NET code embedded into a .NET application.

1e9182fb7b2ffa9112b2fd9efb99148e
0
snikes 101 Dec 29, 2005 at 13:35

@Reedbeta

C++.NET has already been deprecated (MS are no longer supporting it).

Lol, bloody Billy:lol:

340bf64ac6abda6e40f7e860279823cb
0
_oisyn 101 Dec 29, 2005 at 13:53

@Reedbeta

Microsoft is certainly pushing .NET hard. However, And actually, C++.NET has already been deprecated (MS are no longer supporting it).

That’s nonsense, “Managed C++” is deprecated, but they now have C++/CLI (a by ECMA approved international standard!), which is curretly the .Net flagship. If they are no longer supporting it, why would they bother creating a whole new international standard and compiler support for VS2005?

406ad7b52f4ed7443e3971e6b2adf430
0
kariem2k 101 Dec 29, 2005 at 15:08

Hi
Yes there is managed c++ it is c++ but with support to all .Net concepts like
“Common Language Infrastructure (CLI)” ,also there is boost library.
also for GUI instead of “managed c++” which is the easiest you can use WXWidgets it is GUI api for c++.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Dec 30, 2005 at 00:27

Oh, I wasn’t aware of that. I thought Managed C++ and C++.NET were the same thing.

4b382c8236c08850d8931f7e1fabf5d5
0
Vandervecken 101 Dec 30, 2005 at 07:08

@anubis

http://www.boost.org/ that library will provide a lot of the functionality you are looking for.

If you like highly templated helper libraries, Loki [EMAIL=”http://sourceforge.net/projects/loki-lib/”]http://sourceforge.net/projects/loki-lib/[/EMAIL] is one of the best. Written by this guy http://erdani.org/.

But I wouldn’t suggest template libraries to anyone new to C and C++ hehe.

With something like Python/Perl/… it’s all about giving you the toolset in the language, but with C/C++ it is all about defining your own toolset from a basic language (many want C++ to head the route of the formor hence libraries like boost).

1e9182fb7b2ffa9112b2fd9efb99148e
0
snikes 101 Dec 30, 2005 at 08:58

So much to learn…

I know nothing about templates, I remember to have read something about STL but that’s all.

Concerning the “Managed C++” and CLI/C++, I must say that I can’t see what you’re talking about. I found that Microsoft is proposing a free version of Visual C++ with .NET support, but I can’t see how it is working differently from a “standard” C++ application. Is the program including .NET libraries, is the program builded with a special .NET compliant compiler/linker ? Is “managed C++” like a java/cs code, I mean compiled into some kind of bytecode and then interpreted via CLI…

Damn I sound so clueless… :D

Cd577ee1cb56aa2ad5645b7daa0a2830
0
eddie 101 Dec 31, 2005 at 07:00

Visual C++ is just an IDE with a set of compilers/linkers underneath it.

CLI/C++ I don’t know enough about to be authoritative on, but when people say “Managed code”, they generally mean something that’s garbage collected, and often reference counted.

That said, I haven’t worked with this much, so I’m sure someone *cough* .oisyn *cough* will correct me. :)

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Dec 31, 2005 at 08:06

.NET programs consist of a bytecode (called MSIL) which is stored in an ordinary EXE file. When you execute it, a JIT (Just-in-time) compiler translates it from bytecode to machine code. All the .NET languages (VB.NET, C#.NET, C++.NET, etc) compile to the same kind of bytecode, which is why you are able to use class libraries built in one language with programs in another language. The standard libraries, which comprise the CLI (Common Language Infrastructure, damn MS for stealing that acronym from Command Line Interface!) are also useable the same way across all the languages.

340bf64ac6abda6e40f7e860279823cb
0
_oisyn 101 Jan 02, 2006 at 23:30

“Managed C++” and “C++/CLI” are both C++.Net, so you’re compiling to .Net bytecode. The difference between the two is the specific .Net syntax used in C++ code. Managed C++ was the syntax used in VS.Net 2002 and 2003. It uses a lot of ugly reserved words with double underscores.

With C++/CLI, Microsoft standardized a new C++ interface for the common language infrastructure with syntax constructs that blend very well in the language. It has whole new symbols for references and pointers to managed (.Net) objects, and a lot of built-in template-like features to interface with managed objects from unmanaged code (like converting a reference to a managed object to a native C++ pointer) and vice versa.

Da26e799270ce5e8b62659ed77b11cef
0
Axel 101 Jan 03, 2006 at 00:26

@Reedbeta

Microsoft is certainly pushing .NET hard. However, Windows operating systems will be able to run “native” C++ code for a very long time yet. And actually, C++.NET has already been deprecated (MS are no longer supporting it). They recommend using C# or Visual Basic to develop .NET applications.

That’s not true. C++ .NET was replaced by C++/CLI, which has a much nicer syntax.

Edit: Seems like I should read the thread before posting :)

1e9182fb7b2ffa9112b2fd9efb99148e
0
snikes 101 Jan 04, 2006 at 07:39

Thanks for the explanations :)