1
Q:

What is the output of this program?

#include
        using namespace std;
        struct sec {
            int a;
            char b;
        };
        int main()
        {
            struct sec s ={25,50};
            struct sec *ps =(struct sec *)&s;
            cout << ps->a << ps->b;
            return 0;
        }

A) 252 B) 253
C) 254 D) 262

Answer:   A) 252



Explanation:

In this program, We are dividing the values of a and b, printing it.

Subject: C++
Q:

What is friend function?

Answer


The function declaration should be preceded by the keyword friend.The function definitions does not use either the keyword or the scope operator :: The functions that are declared with the keyword friend as friend function.Thus, a friend function is an ordinary function or a member of another class.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

2 3917
Q:

What is dynamic binding?

Answer


Dynamic binding (also known as late binding) means that the code associated with a given procedure call is not known until the time of the call at run time.It is associated with polymorphism and inheritance.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 2400
Q:

What is default constructor?

Answer


A default constructor is a constructor that either has no parameters, or if it has parameters, all the parameters have default values.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 2144
Q:

What is copy constructor?

Answer


Copy constructor is a constructor function with the same name as the class and used to make deep copy of objects.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 2656
Q:

What are storage qualifiers in C++ ?

Answer

ConstKeyword indicates that memory once initialized, should not be altered by a program.
Volatile keyword indicates that the value in the memory location can be altered even though nothing in the program.
Mutable keyword indicates that particular member of a structure or class can be altered even if a particular structure variable, class, or class member function is constant.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 2600
Q:

What do you mean by reference variable in c++?

Answer

A reference variable provides an alias to a previously defined variable.
Data -type & reference-name = variable name

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 2210
Q:

what is the use of virtual destructor in c++?

Answer

A destructor is automatically called when the object is destroyed. A virtual destructor in C++ is used primarily to prevent resource leaks by performing a clean-up of the object.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 1994
Q:

How variable declaration in c++ differs that in c?

Answer

C requires all the variables to be declared at the beginning of a scope but in c++ we can declare variables anywhere in the scope. This makes the programmer easier to understand because the variables are declared in the context of their use.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

1 5127