Container Design

1

Which are the parameters for the content of the buffer?

A. start
B. finish
C. Both a & b
D. None of the mentioned

2

Which of the following type does the container should define?

A. Iterator type
B. Vector type
C. Storage type
D. None of the mentioned

3

How the member functions in the container can be accessed?

A. Iterator
B. Indirect
C. Both a & b
D. None of the mentioned

4

Which is used for manually writing lookup table?

A. std:map
B. std:lookup
C. std:find
D. None of the mentioned

5

What is the output of this program?

1.
    #include 
2.
    #include 
3.
    #include 
4.
    #include 
5.
    using namespace std;
6.
    template
7.
    class SimpleContainer
8.
    {
9.
        public:
10.
        SimpleContainer(size_t xDim, size_t yDim, myType const& defaultValue)
11.
        : objectData(xDim * yDim, defaultValue)
12.
        , xSize(xDim)
13.
        , ySize(yDim)
14.
        {
15.
        }
16.
        myType& operator()(size_t x, size_t y)
17.
        {
18.
            return objectData[y * xSize + x];
19.
        }
20.
        myType const& operator()(size_t x, size_t y) const 
21.
        {
22.
            return objectData[y * xSize + x];
23.
        }
24.
        int getSize()
25.
        {
26.
            return objectData.size();
27.
        }
28.
        void inputEntireVector(vector inputVector)
29.
        {
30.
            objectData.swap(inputVector);
31.
        }
32.
        void printContainer(ostream& stream)
33.
        {
34.
            copy(objectData.begin(), 
            objectData.end(),
35.
            ostream_iterator(stream, ""/*No Space*/));
36.
        }
37.
        private:
38.
        vector objectData;
39.
        size_t  xSize;
40.
        size_t  ySize;
41.
    };
42.
    template
43.
    inline ostream& operator<<(ostream& stream, SimpleContainer& object)
44.
    {
45.
        object.printContainer(stream);
46.
        return stream;
47.
    }
48.
    void sampleContainerInterfacing();
49.
    int main()
50.
    {
51.
        sampleContainerInterfacing();
52.
        return 0;
53.
    }
54.
    void sampleContainerInterfacing()
55.
    {
56.
        static int const ConsoleWidth  = 80;
57.
        static int const ConsoleHeight = 25;
58.
        size_t width  = ConsoleWidth;
59.
        size_t height = ConsoleHeight;
60.
        SimpleContainer mySimpleContainer(width, height, 0);
61.
        cout << mySimpleContainer.getSize() << endl;
62.        
        mySimpleContainer(0, 0) = 5;
63.
    }
A. 2000
B. No Space
C. Error
D. Depends on the compiler