Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Home
»
C++ Programming
»
Functions
What is correct about the following program? #include<iostream.h> class Addition { int x; public: Addition() { x = 0; } Addition(int xx) { x = xx; } Addition operator + (int xx = 0) { Addition objTemp; objTemp.x = x + xx; return(objTemp); } void Display(void) { cout<< x << endl; } }; int main() { Addition objA(15), objB; objB = objA + 5; objB.Display(); return 0; }
The program will print the output 20.
The program will report run time error.
The program will print the garbage value.
Compilation fails due to 'operator +' cannot have default arguments.
Show Answer
Correct Answer:
Compilation fails due to 'operator +' cannot have default arguments.
← Previous
Next →
Discussion & Comments
No comments yet. Be the first to comment!
Name:
Comment:
Post Comment