Archive for the ‘Types, Declarations & Expressions’ Category

The explicit keyword

Assume we have a class that’s doing all kinds of interesting stuff. Its public members could be, e.g.:

class Convertor
{
public:
Convertor();
Convertor(char const *str);
Convertor(Convertor const &other);
~Convertor();
operator char const*();
void anyOtherMemberFunction();
};

Objects of the class Convertor may be constructed using a default constructor and using a char const *. [...]

Continue Reading..
Posted in C/C++ Programming Concepts, Types, Declarations & Expressions

L-Value and R-Value Expressions

Expressions that refer to memory locations are called “l-value” expressions. An l-value represents a storage region’s “locator” value,
or a “left” value, implying that it can appear on the left of the equal sign (=). L-values are often identifiers.
Expressions referring to modifiable locations are called “modifiable l-values.” A modifiable l-value cannot have an array type, [...]

Continue Reading..
Posted in C Tidbits, Generic Programming, Types, Declarations & Expressions

Different signature problem with extern variables

File1.c

File2.c

1 int arr[80];

1 extern int *arr;2 int main()3 {4 arr[1] = 100;5 return 0;6 }

(1) int arr[80];(2) int *arr;
are different things. (1) will "create space" for 80 integers in the data segment. "arr" is just shorthand for that memory location [...]

Continue Reading..
Posted in Uncategorized