Answer Posted / harendra pal
Objects that stand for other objects are called proxy objects or surrogates.
Example:
template<class T>
class Array2D
{
public:
class Array1D
{
public:
T& operator[] (int index);
const T& operator[] (int index) const;
...
};
Array1D operator[] (int index);
const Array1D operator[] (int index) const;
...
};
The following then becomes legal:
Array2D<float>data(10,20);
........
cout<<data[3][6]; // fine
Here data[3] yields an Array1D object and the operator [] invocation on that object yields the float in position(3,6) of the original two dimensional array. Clients of the Array2D class need not be aware of the presence of the Array1D class. Objects of this latter class stand for one-dimensional array objects that, conceptually, do not exist for clients of Array2D. Such clients program as if they were using real, live, two-dimensional arrays. Each Array1D object stands for a one-dimensional array that is absent from a conceptual model used by the clients of Array2D. In the above example, Array1D is a proxy class. Its instances stand for one-dimensional arrays that, conceptually, do not exist.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
When the constructor of a base class calls a virtual function, why doesn't the override function of the derived class gets called?
Can turbo c++ run c program?
Explain differences between alloc() and free()?
Where and why do I have to put the "template" and "typename" keywords?
What is iostream in c++ used for?
What return value must conversion operators have in their declaration?
What is the most powerful coding language?
What is :: operator in c++?
Write a program to concatenate two strings.
In a function declaration what does extern means?
Which bitwise operator is used to check whether a particular bit is on or off?
What is endianness?
What is the full form of stl in c++?
Explain the difference between abstract class and interface in c++?
What are libraries in c++?