GCC -fPIC option

Position Independent Code means that the generated machine code is not dependent on being located at a specific address in order to work. E.g. jumps would be generated as relative rather than absolute. Pseudo-assembly: PIC: This would work whether the code was at address 100 or 1000 Non-PIC: This will only work if the code … Read more

Double pointer array in c++

You probably well know that double* is a pointer to a double element. In the same way, double** is a pointer to a double* element, which is itself a pointer. Again, double*** is a pointer to a double** element, and so on. When you instanciate an array to a type T, you usually do new T [size];. For example, for an array of double, you write new double[size];. If your type T is … Read more

c++ error c2015: too many characters in constant

There are character literals (with ‘) and string literals (with “). Character literals have one character. String literals are arrays of characters. You can’t write something like ‘plus’ because it has more than one character (well technically you can, but it’s a multi-character literal, but lets not go there). Nonetheless, this wouldn’t make any sense because operationptr points at a single char object. … Read more

What is wrong with using goto?

Because they lead to spaghetti code. In the past, programming languages didn’t have while loops, if statements, etc., and programmers used goto to make up the logic of their programs. It lead to an unmaintainable mess. That’s why the CS gods created methods, conditionals and loops. Structured programming was a revolution at the time. goto’s are appropriate in … Read more

Creating an instance of class

Creates an object of type Foo in dynamic memory. foo1 points to it. Normally, you wouldn’t use raw pointers in C++, but rather a smart pointer. If Foo was a POD-type, this would perform value-initialization (it doesn’t apply here). Identical to before, because Foo is not a POD type. Creates a Foo object called foo3 in automatic storage. Uses copy-initialization to create a Foo object called foo4 in automatic storage. Uses Bar‘s … Read more

When to use const char * and when to use const char []

Both are distinctly different, For a start: The First creates a pointer. The second creates an array. Read on for more detailed explanation: The Array version: Creates an array that is large enough to hold the string literal “text”, including its NULL terminator. The array text is initialized with the string literal “text”.The array can be modified at a … Read more

Categories c Tags ,
Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)