-
Classes
What error is caused by the following code ?class TemperatureList { public: TemperatureList( ); private: double * list; int size;};void func(Money amount);[...]int main{ TemperatureList list1; func(list1); return 0;}Choose one answer. a. double free b. divide by zero c. illegal argument d. no error
-
-
-
-
-
-
-
-
-
What is the Size of an Empty Class
What is the logic behind size of an empty class = 1? (As per C++)Ex:class base {};main(){printf("Size of the Empty Class is: %dn", sizeof(base));}It gives output: Size of the Empty Class is: 1I have not got the reason / logic behind this.Can anyone help me?
-
Copy Constructor
Explain what is copy constructor and what is the difference between copy constructor and overloaded assignment operator
-
Static Constant Function
Consider a static const function y() that is private member function of a class Y. What do the static and const mean? When could this function be used?
-
Memory Allocation
When is memory allocated for a function of a class? Is it when the program is complied, or only when the function is called?
-
Base Class Pointer with Derived Object
Base class has some virtual method and derived class has a method with the same name. If we initialize the base class pointer with derived object, calling of that virtual method will result in which method being called?
-
Register Relation
Why p++ is faster than p+1?
-
Classes
Given the following class, what is syntactically wrong with the implementation of the display function?class Rational{public: Rational( ); Rational(int numer, int denom); Rational(int whole); int getNumerator( ); int getDenominator( ); friend void display(ostream& out, const Rational& value);private: int numerator; int denominator;};void display(ostream& out, const Rational& value){ out
-
Operators
In the following code fragment, which is the calling object for the less-than operator?string s1, s2;if( s1 < s2 )Choose one answer. a. s1 b. < c. s2 d. none
-
-
-
Operators
Which of the following operators cannot be overloaded?Choose one answer. a. [ ] b. == c. . d. =
C++ Interview Questions
Ans