|
INTERVIEW QUESTIONS
PROGRAMMING LANGUAGES
C++
DETAILS
Question: What are proxy objects?
Answer: Objects that stand for other objects are called proxy objects or surrogates. 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.
|
|
|
Category |
C++ Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.3) By 6577 users |
Added on |
7/16/2015 |
Views |
69552 |
Rate it! |
|
|
Question:
What are proxy objects?
Answer:
Objects that stand for other objects are called proxy objects or surrogates. 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. Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
What are the conditions that have to be met for a condition to be an invariant of the class?
|
View Answer
|
|
Define precondition and post-condition to a member function.
|
View Answer
|
|
What do you mean by Stack unwinding?
|
View Answer
|
|
What is class invariant?
|
View Answer
|
|
What is a Null object?
|
View Answer
|
|
What is an adaptor class or Wrapper class?
|
View Answer
|
|
What is a dangling pointer?
|
View Answer
|
|
What is an incomplete type?
|
View Answer
|
|
What is an Iterator class?
|
View Answer
|
|
What is the use of ‘using’ declaration.
|
View Answer
|
|
When does a name clash occur?
|
View Answer
|
|
What is a modifier?
|
View Answer
|
|
Virtual Destructor - What is the need for Virtual Destructor
|
View Answer
|
|
What is output equal to in Bitwise Operations
|
View Answer
|
|
What’s the auto keyword good for?
|
View Answer
|
|
What does extern mean in a function declaration?
|
View Answer
|
|
What's the best way to declare and define global variables?
|
View Answer
|
|
How do you decide which integer type to use?
|
View Answer
|
|
How do you write a function that can reverse a linked-list?
|
View Answer
|
|
What is the difference between declaration and definition?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All C++ Interview Questions & Answers - Exam Mode /
Learning Mode
|