Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

Search the Tips
Tip Bank > C++ > Functions

Functions - Page 4

61-80 of 109     Previous     Next
The getenv() Function
by Danny Kalev
The ANSI function getenv() returns the value of an environment variable. getenv() takes a C-string containing an environment variable and returns its value. In the following example, getenv() detects ...
Understanding Member Function Lookup Rules
by Danny Kalev
Function lookup stops at a scope. In the case of class hierarchies, this means that a function—either virtual or not—declared in a derived class can hide a virtual member function with the ...
Tackling a Common Bug With scanf()
by Danny Kalev
In legacy code and environments that support C exclusively, using scanf() is still a widespread method of getting input from a user (or a file, when using fscanf()). When using this function, beware ...
Recursion in the Real World
by Danny Kalev
Computer science sophomores learn that recursion can neatly solve complex problems, e.g., Hanoi rings, wildcard handling, and parsing. In practice, however, recursion can be problematic for several ...
Calculating the Size of an Incomplete Array
by Danny Kalev
An incomplete array declaration can appear in a function's parameter list. For ...
Hide Function Pointer Declarations With a typedef
by Danny Kalev
Can you tell what the following declaration ...
The snprintf() Function
by Danny Kalev
The C99 standard defines a new version of the function sprintf(), namely snprintf(), with the following ...
The "Single Exit Point" Idiom — Is It Still Relevant?
by Danny Kalev
Many programming schools recommend that functions have only a single exit point. For example, the following function is considered bad programming practice because it contains three potential exit ...
When Is It Safe to Use Inline?
by Danny Kalev
Excessive use of inline functions might bloat the size of the executable and reduce execution speed. In other words, using inline abundantly can degrade rather than enhance performance. For ...
Calling a Member Function From a Destructor
by Danny Kalev
< ...
Declaring a Volatile Member Function
by Danny Kalev
< ...
Avoid Passing Arguments With Side Effects to C Runtime Library Functions
by Danny Kalev
Many of the C Runtime Library functions are in fact macros in disguise. < stdlib.h> routines, memset(), strcpy() and others are often implemented as macros that perform some low-level system call. ...
Array of Objects
by DevX Pro
I have two questions. How do I pass an array of objects as an argument? How do I fix an error like "do or while loops are not expanded inline"?
More on Default Arguments
by Danny Kalev
The order of evaluation of function arguments is unspecified. Consequently, parameters of a function may not be used in default argument expressions. For example, the following declaration is ...
Limitations on the Location of a Default Arguments Declaration
by Danny Kalev
Default arguments shall be specified only in the parameter-declaration-clause of a function declaration or in a template-parameter. This means that default arguments cannot appear in declarations of ...
Default Arguments are not Part of a Function's Type
by Danny Kalev
Although the default arguments of a function must appear in its declaration, they are not considered part of its type. Thus, you cannot overload a function by using different default ...
Declaring References to Functions
by Danny Kalev
You can declare a reference to a function, just like you can declare a pointer to a function. For ...
A Member Function Template may not be Virtual
by Danny Kalev
A reader tried to declare a template as a virtual member function of a class. However, his compiler refused to compile the code. The reader wanted to know what he was doing wrong. The answer is ...
Living Without Null References
by Danny Kalev
In C, algorithms that rely on pointers such as bsearch() and lfind() return a null pointer to indicate that the sought after element wasn't found. Unlike a pointer, a reference must always be bound ...
Beware of Object Slicing
by Danny Kalev
Passing a derived object by value to a function that takes a base object by value may cause a problem known as "object slicing"; every additional data member declared in the derived object is omitted.
61-80 of 109     Previous     Next
Thanks for your registration, follow us on our social networks to keep up-to-date