How to do something in C++ (besides traverse binary trees)

Based on How to feel useful, here is a guide to the five steps for making a programming language actually feel useful, for C++ in particular:

1. Graphics – Make some windows! (google “windowing toolkit”)

Usually operating systems will offer some sort of programming library so you don’t have to reinvent the window. This varies from Windows to Mac to Linux. Additionally, there are windowing toolkits – downloadable libraries that let you make windows that work anywhere.
GTK, the GIMP toolkit, is best known for being used in many open source programs, like the GIMP (of course), GAIM, and DIA are built in. There is a tutorial, though it’s not entirely transparent.

Possibly preferable are Qt, a partially-open-source toolkit [tutorial], and wxWidgets [tutorial].

2. Web Browsing (google “C++ http library”)

One of the simpler ways of pulling web pages is through the use of http-fetcher, a portable library for making HTTP requests.

If you’re willing to stick to Windows-only (and .NET only in particular), this shows how. .NET has a fat library though, so if you’re using it you won’t need the rest of this.

3. File Manipulation

C++ has built in file handling (and more importantly, a good C++ tutorial will typically document this). Reading a file line by line is pretty straightforward [tutorial].

4. System calls

Use system() to make calls to other command line programs. [reference]

5. Redistributables

Fortunately, native compilability is C++’s h2 suit. In general, using a standard C++ compiler (the Microsoft compiler or G++, for instance), you get a binary file that can be run on any other computer (using the same operating system, of course).

—-

The Boost library is one of the most important C++ library collections, as well as one that will have a major impact on the next version of C++ (as Bjarne Sjourstrup, the creator of C++, said at a recent talk). It’s available at http://www.boost.org/. Most of it is lower level than what we’re talking about here, though.

—-

The updating version is available at http://canadia.strafenet.com/index.php?title=Programmer%27s_Thesaurus

Comments

  1. Tim says:

    Don’t encourage noob programmers to use system(). I’ve graded enough intermediate level C++ homework to know that this gets abused waaaay too much.

  2. Chuck says:

    pfft. This is way overkill for making minesweeper, and I am unaware of any other potential programming options I may want to write.

  3. Chris says:

    While we’re at it, why are you writing minesweeper? I know a great minesweeper program that you can get without writing any code.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>