I’ll postpone the development of this blog until standards settle…

Posted in 1 on November 18, 2009 by Baltazaar

C++ is in an evolutionary state these days. Not to say that you can’t learn C++ as is, but I was was hoping to use the latest addition frome the core of the language, because this will ease the learning and understanding of the fundamental concepts in some areas.

Until then, I’ll try to prepare a little Python for CG page on my other blog, http://baltazaar.wordpress.com

 

 

Did yoy know? A little sidenote…

Posted in Tech yourself C++ (in 5 years) on August 3, 2009 by Baltazaar

I’m going to keep on posting to this site, even if I’ve been away for a while.

With the introduction of the new C++ 09 Standard (C++0x), more programmers are going to turn to C++ for their coding needs, that’s what I think, anyway.

I’m going to include these new constructs, when the target is reached in conjunction with earlier posts…

But, did you know, that after the C90 standard (ANSI C) every programming example/tutorial written in the book “The C Programming Language, Second Edition” by Kernighan/Ritchie is a valid C++ program?

So, if you want to get into some basic C programming before embarking the road to the more ambitious object oriented C++, there is no stopping you from learning something about the statically typed C language. It is not a big book, it counts only 260 pages, and is well worth a read. It covers every important concept in the C90 language.

You can get the book here:

The C Programming Language 2 edt.

Just remember that cases regarding explicit casts in C is not widely employed in a simmilar manner in C++, and Macro’s are not very useful either, as we use const and enum data types for manifest constants in C++.

I’ll try to make this page a bit more “tutorial alike” as I get the time for it.

Basic input/output

Posted in Tech yourself C++ (in 5 years) with tags , , on May 10, 2008 by Baltazaar

Here is a snippet that reads two string variables from the console, and writes them out. Not much to write home about… Explanation follows.


#include <iostream>
#include <string>

using namespace std; //This is not pretty in global namespace scope, but we’ll learn…

int main(){

string fname, lname;
cout <> fname;
cout <> lname;

// Output to console:
cout << “Hello ” << fname << ” ” << lname << “!” << endl;

return 0;
}

Babysteps, the compiler

Posted in Tech yourself C++ (in 5 years) on May 9, 2008 by Baltazaar

To get our C++ program to run, we have to translate it into a machine language program, or let’s say an executable. To do this we need a couple of things.

Let’s start with a C++ compiler. To keep it simple for now, we’ll drop some intermediate steps and say that what the compiler primarily does is:

1. Assigning memory addresses to variables. This allows us to use names for variables, rather than having to keep track of the address of each variable ourselves.

2. Translating arithmetic and other operations (such as +, , etc.) into the equivalent machine instructions, including the addresses of variables assigned in the previous step.
Each complete operation understood by the compiler is called a statement, and ends with a semicolon (;).
An example could be:
int age = 32;

This tells the compiler to make room for an integer in memory and assign the variable “age” the value of 5. This is called a “statement”. Values are assigned from right to left, so in case of:
age = age + 10;
The calculation of age + 10 is done before assigning the new value back into the already initialized age variable of type int.

Some definitions

Posted in Tech yourself C++ (in 5 years) with tags on May 9, 2008 by Baltazaar

A machine instruction is one of the fundamental operations that a CPU can perform. Some examples of these operations are addition, subtraction, or other arithmetic operations; other possibilities include operations that control what instruction will be executed next. All C++ programs must be converted into machine instructions by a compiler before they can be executed by the CPU.

An assembly language program is the human-readable representation of a set of machine instructions; each assembly language statement corresponds to one machine instruction. By contrast, a C++ program consists of much higher-level operations which cannot be directly translated one-for-one into machine instructions.

What is a digit?

Posted in Tech yourself C++ (in 5 years) on May 9, 2008 by Baltazaar

A digit is one of the characters used in any positional numbering system to represent all numbers starting at 0 and ending at one less than the base of the numbering system. In the decimal system, there are ten digits, 0 – 9, and in the hexadecimal system there are sixteen digits, 0 – 9 and a – f.

A binary number system is one that uses only two digits, 0 and 1.

A hexadecimal number system is one that uses sixteen digits, 0 – 9 and a – f.

To C or not to C

Posted in Tech yourself C++ (in 5 years) on May 9, 2008 by Baltazaar

Bjarne Stroustrup, on page 169 of his book, The Design and Evolution of C++, he says:

“Learn C++ first. The C subset is easier to learn for C/C++ novices and easier to use than C itself.”

So let’s start there.