Cpp Programming Quiz 48 – Which one of the following options is correct?
[B]. Friend function can access protected data members of the class.[C]. Friend function can access private data members of the class.
[D]. All of the above.
Answer: Option D
Answer: Option D
#include
class BixBase
{
int x, y;
public:
BixBase(int xx = 10, int yy = 10)
{
x = xx;
y = yy;
}
void Show()
{
cout<< x * y << endl;
}
};
class BixDerived
{
private:
BixBase objBase;
public:
BixDerived(int xx, int yy) : objBase(xx, yy)
{
objBase.Show();
}
};
int main()
{
BixDerived objDev(10, 20);
return 0;
}
[A].The program will print the output 100.
[B].The program will print the output 200.
[C].The program will print the output Garbage-value.
[D].The program will report compile time error.
Answer: Option B
Answer: Option B
[B].
Answer: Option A
Explanation:
Yes, It is possible to allocate a block of memory (of arbitrary size) at run-time, using the standard library’s malloc function, and treat it as an array.
Answer: Option C
#include
class Number
{
int Num;
public:
Number(int x = 0)
{
Num = x;
}
void Display(void)
{
cout<< Num;
}
void Modify();
};
void Number::Modify()
{
int Dec;
Dec = Num % 13;
Num = Num / 13;
if(Num > 0 ) Modify() ;
if(Dec == 10) cout<< "A" ;
else if(Dec == 11) cout<< "B" ;
else if(Dec == 12) cout<< "C" ;
else if(Dec == 13) cout<< "D" ;
else cout<< Dec ;
}
int main()
{
Number objNum(130);
objNum.Modify();
return 0;
}
[A].130
[B].A0
[C].B0
[D].90
Answer: Option B
virtual function
[C].
destructor
[D].
main
Answer: Option A
Explanation:
No answer description available for this question.