3
Q:

What is the output of this program ?

       #include
        using namespace std;
        int n(char, int);
        int (*p) (char, int) = n;
        int main()
        {
            (*p)('d', 9);
            p(10, 9);
            return 0;
        }
        int n(char c, int i)
        {
            cout << c <<  i;
            return 0;
        }

A) d99 B) d9d9
C) d9 D) compile time error

Answer:   A) d99



Explanation:

In this program, we have declared the values as integer instead of character, So it is printing as d99 but it will not arise an error.

Subject: C++
Q:

What is the scope resolution operator?

Answer

Scope resolution operator allows a program to reference an identifier in the global scope that is hidden by another identifier with the same name in the local scope.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

1 3890
Q:

Difference between Stack and Queue

Answer

Stack is a collection of objects that works in LIFO (Last in First out) mechanism while Queue is FIFO (First in First out). This means that the object that is inserted first is removed last in a stack while an object that is inserted first is removed first in a queue.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 4913
Q:

What do you mean by stack unwinding?

Answer

Stack unwinding is a process of calling all destructors for all automatic objects constructed at run time when an exception is thrown. Destructors are called between the places where the exception was thrown and where it is caught.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 2750
Q:

What is a Wrapper class?

Answer

Wrapper classes wrap primitive values in a class and offers utility to access them through objects. Some of the primitive wrapper data types are:


Byte, short, int, long, float, double, char, Boolean.


Example: 


Create a class name VectorAdd to populate it with integer values using the add(int, object) method.


public class VectorAdd


{


       public static void main(String argv[])


       {


             Vector v = new Vector();


             v.add(0,new Integer(10));


             v.add(1,new Integer(20));


             v.add(2,new Integer(30));


             for(int i=0; i < v.size();i ++)


             {


                  Integer iw =(Integer) v.get(i);


                  System.out.println(iw);


             }


       }


}

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 3507
Q:

Exlpain STL.

Answer

STL stands for Standard Template Library. It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 2937
Q:

.What are Stacks? Give an example where they are useful.

Answer

A Stack is a linear structure in which insertions and deletions are always made at one end i.e the top - this is termed as last in, first out (LIFO). Stacks are useful when we need to check some syntex errors like missing parentheses. 

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 3409
Q:

What are the advantages of using friend classes?

Answer

- Friend classes are useful when a class wants to hide features from users which are needed only by another, tightly coupled class. 


- Implementation details can be kept safe by providing friend status to a tightly cohesive class.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 3738
Q:

Explain one-definition rule (ODR).

Answer

According to one-definition rule, C++ constructs must be identically defined in every compilation unit they are used in. 


As per ODR, two definitions contained in different source files are called to be identically defined if they token-for-token identical. The tokens should have same meaning in both source files. 


Identically defined doesn’t mean character-by-character equivalence. Two definitions can have different whitespace or comments and yet be identical.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 2703