Question & Additional Information
 
can you add two pointers ?
Add to My IQ
 

Answer Title
Answer

Yes, but...pointers are numeric memory addresses (they are like zip codes that tell where your objects are stored in memory). Although you could add two pointers together, the answer is indeterminant and wouldn't serve any purpose.

Question Tag Title
Tags
Question Asked At Title
Asked At
None
Question Job Title
Job Titles
None


Check out our newest job listings!

Post a Job! $49 for 60 days



Your Name:
Add your comment text
 
Related Questions
Related Questions
Flag this interview question as inappropriate Inappropriate
See Answer

structures can be passed by reference.

they can be returned as pointers.

Create Date
:
Saturday, March 15, 2008
Asked At
:
None
Job Positions
:
Click here to improve the Interview Question, Answer and other fields.
Comments (0) :
Goto add your comment on the Question 
Flag this interview question as inappropriate Inappropriate
See Answer
Iterators are coming under STL (Standard Template Library)Iterators are act like pointers.Types of Iterators:1. Reverse Iterators: a) Random access - store & retrieve values, random access (RandIter) b) Bidirectional - store & retrieve values, forward & backward moving (BiIter)2. Forward Iterator - store & retrieve values, forward moving only (ForIter)3. Input Iterator - retrieve values, forward moving only (InIter)4. Output Iterator - store values, forward moving only (OutIter).
Create Date
:
Saturday, March 15, 2008
Tags
:
Asked At
:
None
Job Positions
:
Click here to improve the Interview Question, Answer and other fields.
Comments (0) :
Goto add your comment on the Question 
Flag this interview question as inappropriate Inappropriate
See Answer

We can assign the memory dynamically for a 1 dimensional array in the following way:

int *a;
int i; //Can be any value
a = (int *)malloc (i * sizeof(int));

Dynamic allocation of arrays of more than one dimension is not so easily done, because dynamic allocation of an n-dimensional array actually requires dynamic allocation of n 1-dimensional arrays. To allocate a 2-dimensional array you must first allocate memory sufficient to hold all the elements of the array (the data), then allocate memory for pointers to each row of the array. For arrays of more than two dimensions it gets more complicated.

Create Date
:
Saturday, March 15, 2008
Asked At
:
None
Job Positions
:
Click here to improve the Interview Question, Answer and other fields.
Comments (0) :
Goto add your comment on the Question 
Flag this interview question as inappropriate Inappropriate
See Answer
Memory leak is - dynamically allocating memory and forgeting to free it. In C++, using a new operator to allocate a chunk of memory, and forgetting to delete it. There are several reasons this could occur. Some of them are,
1. Allocate a chunk of memory and assign the starting address to a pointer variable, and later, reassing another address to the same pointer without freeing its original address
2. Allocate memory for an array and not using proper delete method (delete[]) to free the memory
3. Unhandled exceptions - allocating memory and deleting it at the end of the program, but the program abnormally terminates (crashes) before the delete code line is executed.

Some of the ways of avoiding memory leaks within a class object are
1. Allocate all dynamic memory required for the class in the constructor, and delete it in the distructor
2. Use TRY/CATCH blocks around all statements where there is a possiblity of a crash
3. Override new operator for your class and Track memory allocations and pointers. Override delete operator and untrack the deleted/freed memory. In the destructor, check to see if there are any tracked memory locations (not freed) and free them up.
But beyond all these, it's still a good programming style that avoids memory leaks, because beyond objects, there is a program where you instantiate and run these objects. If you are allocating memory dynamically in the parent program, then carefully make sure you delete those chunks at all exit points (or centralize your exit point).
Create Date
:
Saturday, March 15, 2008
Tags
:
Asked At
:
None
Job Positions
:
Click here to improve the Interview Question, Answer and other fields.
Comments (0) :
Goto add your comment on the Question 
Flag this interview question as inappropriate Inappropriate
See Answer
Smart pointers are objects which store pointers to dynamically allocated (heap) objects. They behave much like built-in C++ pointers except that they automatically delete the object pointed to at the appropriate time. Smart pointers are particularly useful in the face of exceptions as they ensure proper destruction of dynamically allocated objects. They can also be used to keep track of dynamically allocated objects shared by multiple owners
Create Date
:
Saturday, March 15, 2008
Tags
:
Asked At
:
None
Job Positions
:
Click here to improve the Interview Question, Answer and other fields.
Comments (1) :
1.
sargam
Saturday, March 15, 2008 12:27 PM
this is a smart question ...
I was asked for microsoft..
Flag this interview question as inappropriate Inappropriate
See Answer
Wild pointers are also known as Dangling pointers. Pointers that do not point to a valid object of the appropriate type, or to a distinguished null pointers value in language which support this.
Create Date
:
Saturday, March 15, 2008
Tags
:
Asked At
:
None
Job Positions
:
Click here to improve the Interview Question, Answer and other fields.
Comments (0) :
Goto add your comment on the Question 
 
• More Related Questions: