background preloader

C++

Facebook Twitter

Boost C++ Libraries. C Consultant : Contract Software Engineering : Free Sample Code : OpenHatch - Community tools for free and open source software. C++ - Best practices for debugging linking errors. Executive Summary. SWIG is an interface compiler that connects programs written in C and C++ with scripting languages such as Perl, Python, Ruby, and Tcl. It works by taking the declarations found in C/C++ header files and using them to generate the wrapper code that scripting languages need to access the underlying C/C++ code. In addition, SWIG provides a variety of customization features that let you tailor the wrapping process to suit your application. John Ousterhout (creator of Tcl) has written a paper that describes the benefits of scripting languages.

SWIG makes it fairly easy to connect scripting languages with C/C++ code. SWIG is used in a number of ways: Building more powerful C/C++ programs. Using SWIG, you can replace the main() function of a C program with a scripting interpreter from which you can control the application. A number of papers and tutorials describing SWIG are available. EveryJS.com. The C++ 'const' Declaration: Why & How. The 'const' system is one of the really messy features of C++. It is simple in concept: variables declared with ‘const’ added become constants and cannot be altered by the program. However it is also used to bodge in a substitute for one of the missing features of C++ and there it gets horridly complicated and sometimes frustratingly restrictive. The following attempts to explain how 'const' is used and why it exists. Simple Use of ‘const’ The simplest use is to declare a named constant.

To do this, one declares a constant as if it was a variable but add ‘const’ before it. Const int Constant1=96; will create an integer constant, unimaginatively called ‘Constant1’, with the value 96. Such constants are useful for parameters which are used in the program but do not need to be changed after the program is compiled. It also works with pointers but one has to be careful where ‘const’ is put as that determines whether the pointer or what it points to is constant.

Const int * Constant2. The Go Programming Language. Code University - Google Code. On TermKit | Steven Wittens - Acko.net. I've been administering Unix machines for many years now, and frankly, it kinda sucks.

It makes me wonder, when sitting in front of a crisp, 2.3 million pixel display (i.e. a laptop) why I'm telling those pixels to draw me a computer terminal from the 80s. And yet, that's what us tech nerds do every day. The default Unix toolchain, marked in time by the 1970 epoch, operates in a world where data is either binary or text, and text is displayed in monospace chunks. The interaction is strictly limited to a linear flow of keystrokes, always directed at only one process.

The Unix philosophy talks about software as a toolset, about tiny programs that can be composed seamlessly. In the meantime, we've gotten a lot better at displaying information. And yet the world of Unix is rife with jargon, invisible processes, traps and legacy bits. So while I agree that having a flexible toolbox is great, in my opinion, those pieces could be built a lot better. Rich Display Pipes So how do we fix this? JS/UIX - Terminal. Template Metaprogramming in C++ When do we use Initializer List in C++?

Initializer List is used to initialize data members of a class. The list of members to be initialized is indicated with constructor as a comma separated list followed by a colon. Following is an example that uses initializer list to initialize x and y of Point class. The above code is just an example for syntax of Initializer list. In the above code, x and y can also be easily initialed inside the constructor. But there are situations where initialization of data members inside constructor doesn’t work and Initializer List must be used. Following are such cases: 1) For initialization of non-static const data members: const data members must be initialized using Initializer List. 2) For initialization of reference members: Reference members must be initialized using Initializer List. 3) For initialization of member objects which do not have default constructor: In the following example, an object “a” of class “A” is data member of class “B”, and “A” doesn’t have default constructor. 3.

An Idiot's Guide to C++ Templates - Part 1. Prolusion Most C++ programmers stay away from C++ templates due to their perplexed nature. The excuses against templates: Hard to learn and adapt. Compiler errors are vague, and very long. Not worth the effort. Admitted that templates are slightly hard to learn, understand, and adapt. While C++ templates and STL (Standard Template Library) are siblings, technically. Table of Contents The Syntax Drama As you probably know, template largely uses the angle brackets: The less than ( < ) and the greater than ( > ) operators. Where Content can be: class T / typename T A data type, which maps to T An integral specification An integral constant/pointer/reference which maps to specification mentioned above. For point 1 and 2, the symbol T is nothing but some data-type, which can be any data-type - a basic datatype (int, double etc), or a UDT.

Let's jump to an example. Which can be called passing an int: PrintTwice(120); Templates are of two types: Function Templates Class Templates No, my boy!