Cpp Programming 78 – Which of the following provides a reuse mechanism?
[B]. Inheritance[C]. Dynamic binding
[D]. Encapsulation
Answer: Option B
Answer: Option B
#include
struct BixArray
{
int arr[5];
public:
void BixFunction();
void Display();
};
void BixArray::BixFunction()
{
static int i = 0, j = 4;
i++;
j--;
if(j > 0)
BixFunction();
int tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
i--;
j++;
}
void BixArray::Display()
{
for(int i = 0; i < 5; i++)
cout<< arr[i] << " ";
}
int main()
{
BixArray objArr = {{5, 6, 3, 9, 0}};
objArr.BixFunction();
objArr.Display();
return 0;
}
[A].5 6 3 9 0
[B].0 9 3 6 5
[C].0 5 6 3 9
[D].0 6 3 9 5
Answer: Option D
destructor
[C].
function
[D].
object
Answer: Option B
Explanation:
No answer description available for this question.
#include
class Bix
{
public:
int x;
};
int main()
{
Bix *p = new Bix();
(*p).x = 10;
cout<< (*p).x << " " << p->x << " " ;
p->x = 20;
cout<< (*p).x << " " << p->x ;
return 0;
}
[A].10 10 20 20
[B].Garbage garbage 20 20
[C].10 10 Garbage garbage
[D].Garbage garbage Garbage garbage
Answer: Option A
Answer: Option B
The compiler always provides a zero argument constructor.
[C].
It is necessary that a constructor in a class should always be public.
[D].
Both B and C.
Answer: Option D
Explanation:
No answer description available for this question.
Answer: Option D