Cpp Programming 76 – Which of the following statements is correct in C++?
[B]. Structures can have functions as members.[C]. Class members are public by default.
[D]. Structure members are private by default.
Answer: Option B
Answer: Option B
#include
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;
}
[A].The program will print the output 20.
[B].The program will report run time error.
[C].The program will print the garbage value.
[D].Compilation fails due to 'operator +' cannot have default arguments.
Answer: Option D
[A].
Only 1 is correct.
[B].Only 2 is correct.
[C].
Both 1 and 2 are correct.
[D].
Both 1 and 2 are incorrect.
Answer: Option D
Explanation:
No answer description available for this question.
The program will print the output Bix.
[C].
The program will print the output IndiaBix.
[D].
The program will report compile time error.
Answer: Option C
Explanation:
No answer description available for this question.
Answer: Option A
Answer: Option D
[C]. Class is an instance of data type.
[D]. Object is an instance of data type.
Answer: Option B