What are proxy objects?

Answers were Sorted based on User's Feedback



What are proxy objects?..

Answer / 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

What are proxy objects?..

Answer / harendra pal

Objects that points to other objects are called proxy objects or surrogates. Its an object that provides the same interface as its server object but does not have any functionality. During a method invocation, it routes data to the true server object and sends back the return value to the object.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

Why do we need constructors in c++?

0 Answers  


Why do we need runtime polymorphism in c++?

0 Answers  


Which command properly allocates memory a) char *a=new char[20]; b) char a=new char[20]; c) char a=new char(20.0);

0 Answers  


What is the iunknown interface?

0 Answers  


What do you understand by pure virtual function? Write about its use?

0 Answers  


what do you mean by memory management operators

4 Answers   HCL,


What is meant by forward referencing and when should it be used?

0 Answers  


What is decltype c++?

0 Answers  


How can you quickly find the number of elements stored in a dynamic array?

0 Answers  


What is srand c++?

0 Answers  


In which header file does one find isalpha() a) conio.h b) stdio.h c) ctype.h

0 Answers  


what is multi-threading in C++?

0 Answers  


Categories