Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
Search the Tips
Tip Bank > C++ > Pointer Arithmetic

Pointer Arithmetic - Page 4

61-79 of 79     Previous     Next
Prefer Function Objects to Function Pointers
by Danny Kalev
Passing a function pointer is a common practice in event-driven systems, whereby a callback routine is invoked through a pointer. C++, however, offers a better alternative to function pointers: ...
double pointer
by DevX Pro
Please describe the primary use of the double pointer in C and C++; that is, **pointer.
void pointers
by DevX Pro
I am having trouble converting the info in a void pointer to usable information. I have a method that returns a void pointer (void*), and in one instance (the first in the compiler) I want to put the info into a string. What code do I use to convert or cast the void pointer to a string variable?
Returning strings from functions
by DevX Pro
I would like to write a function that receives an integer and converts this into a string representing the integers value in binary. At the moment I am struggling to get the function to return a string. Do I have to get the function to return a pointer to the string? If so how is this declared and called?
Always Initialize Pointers
by Danny Kalev
An uninitialized pointer has an indeterminate value. It's almost impossible to test subsequently whether such a pointer is valid, especially if it is passed as an argument to a function, which in ...
Data Pointers vs. Function Pointers
by Danny Kalev
C and C++ make a clear-cut distinction between two types of pointers: data pointers and function pointers. A function pointer embodies several constituents such as the list of arguments, a return-to ...
A Pointer to Member Cannot Refer to a Static Member Function
by Danny Kalev
It is illegal to assign the address of a static class member to a pointer to member. However, you can take the address of a static member function of a class and treat it as if it were an external ...
Pointers to Members of a Template Class
by Danny Kalev
You can define a pointer to a class template member. For example, you can use the specialization ...
User-defined string functions
by DevX Pro
I am moving from other languages to Visual C++. I am trying to write a function that returns a string (or pointer to a string), which will then be put into a buffer using the lstrcpy function. I get only the first letter.
Avoid Deleting a Pointer More Than Once
by Danny Kalev
The results of deleting an object more than once are undefined. However, if code modifications are impossible (when a third party code is used, for example), a temporary workaround to this bug is ...
Returning Objects by Value
by Danny Kalev
For efficiency reasons, large objects should usually be passed to or returned from a function by reference or by their address (using a pointer). There are, however, a few circumstances in which the ...
Beware of Aliasing
by Danny Kalev
Whenever your class contains pointers, references, or handles, you need to define a copy constructor and assignment operator. Otherwise, the compiler-generated copy constructor and assignment ...
Functions should not return a reference to a local object
by Danny Kalev
A reference is always bound to the same object. When that object is destroyed, any use of its reference yields undefined behavior. The following example may demonstrate ...
auto_ptr<>: your safe guard against memory leaks
by Danny Kalev
The Standard Library supplies the class template auto_ptr<> which automatically deallocates heap memory. Likewise, local objects are reclaimed in case of exiting their scope or during "stack ...
How to use a pointer to a pointer to an int
by DevX Pro
How do you use a pointer to a pointer to an int? Like this: -------------- int **IntPtr; -------------- How do you access the value "underneath" two pointers?
Pointers
by DevX Pro
On a test in college an instructor asked if it was possible to multiply and divide pointers. In the book we are using it says nothing about it, and I was just wondering if you could.
No Pointer Arithmetics Outside Array Bounds!
by Karsten Weihe
Sometimes it is tempting to let a pointer point to a location that ...
Constant pointers
by Danny Kalev
There are cases when you need to define a constant pointer to a variable/object; for instance, when taking a function address, or when you want to protect a pointer from unintended modifications such ...
Prefer References Over Pointers
by Danny Kalev
Even experienced C++ programmers who have prior experience with C tend to use pointers excessively whereas references may be a better choice. Pointers may result in bugs like the ...
61-79 of 79     Previous     Next
Sitemap