background preloader

Coding

Facebook Twitter

Pointers

Test Driven Development. Programming Tutorials: C++ Made Easy and C Made Easy. Welcome!

Programming Tutorials: C++ Made Easy and C Made Easy

If you're new to C++, I recommend you purchase my ebook, Jumping into C++, a complete step-by-step guide for beginners. C++ Language Tutorial. This website uses cookies.

C++ Language Tutorial

By continuing, you give permission to deploy cookies, as detailed in our privacy policy. ok Search: Doxygen. Generate documentation from source code Doxygen is the de facto standard tool for generating documentation from annotated C++ sources, but it also supports other popular programming languages such as C, Objective-C, C#, PHP, Java, Python, IDL (Corba, Microsoft, and UNO/OpenOffice flavors), Fortran, VHDL, Tcl, and to some extent D.

Doxygen

Doxygen can help you in three ways: It can generate an on-line documentation browser (in HTML) and/or an off-line reference manual (in ) from a set of documented source files. There is also support for generating output in RTF (MS-Word), PostScript, hyperlinked PDF, compressed HTML, and Unix man pages. The documentation is extracted directly from the sources, which makes it much easier to keep the documentation consistent with the source code.

Doxygen is developed under Mac OS X and Linux, but is set-up to be highly portable. Doxygen license Copyright © 1997-2016 by Dimitri van Heesch. Sponsored links(not related to doxygen) Google C++ Style Guide. Definition: Streams are a replacement for printf() and scanf().

Google C++ Style Guide

Pros: With streams, you do not need to know the type of the object you are printing. You do not have problems with format strings not matching the argument list. (Though with gcc, you do not have that problem with printf either.) Streams have automatic constructors and destructors that open and close the relevant files. Cons: Streams make it difficult to do functionality like pread().

Decision: Do not use streams, except where required by a logging interface. There are various pros and cons to using streams, but in this case, as in many other cases, consistency trumps the debate. Extended Discussion There has been debate on this issue, so this explains the reasoning in greater depth. Proponents of streams have argued that streams are the obvious choice of the two, but the issue is not actually so clear.

Cout << this; // Prints the address cout << *this; // Prints the contents. Introduction to Make. Introduction to Make by Jennifer Vesperman 01/31/2002 Make originated as a system for building compiled code.

Introduction to Make

It is now used as a system for making changes across many files and directories. It is useful whenever a change in one file requires changes or actions elsewhere. Make is useful for system administrators as well as developers. Running Make Make requires a configuration file. The usual name for this file is Makefile; the capitalization lists the makefile with README and other special files. When run with no arguments, GNU Make looks for the configuration files named GNUmakefile, Makefile, and makefile in the current working directory. The makefile in this example displays make complete and does nothing else. $ls makefile renamed_makefile $make echo make complete make complete $make -f renamed_makefile echo make complete make complete $make -s make complete Simple Makefiles The examples in this article are written for C, and produce the sample target file. Vector. Vectors are sequence containers representing arrays that can change in size.

vector

Just like arrays, vectors use contiguous storage locations for their elements, which means that their elements can also be accessed using offsets on regular pointers to its elements, and just as efficiently as in arrays. But unlike arrays, their size can change dynamically, with their storage being handled automatically by the container. Internally, vectors use a dynamically allocated array to store their elements. This array may need to be reallocated in order to grow in size when new elements are inserted, which implies allocating a new array and moving all elements to it.

This is a relatively expensive task in terms of processing time, and thus, vectors do not reallocate each time an element is added to the container. Therefore, compared to arrays, vectors consume more memory in exchange for the ability to manage storage and grow dynamically in an efficient way.