Cpp Programming 99 – Which of the following term is used for a function defined inside a class?
[B]. Member function
[D]. Classic functionAnswer: Option B
Answer: Option B
#include
struct Bix
{
short n;
};
int main()
{
Bix b;
Bix& rb = b;
b.n = 5;
cout << b.n << " " << rb.n << " ";
rb.n = 8;
cout << b.n << " " << rb.n;
return 0;
}
[A].It will result in a compile time error.
[B].The program will print the output 5 5 5 8.
[C].The program will print the output 5 5 8 8.
[D].The program will print the output 5 5 5 5.
Answer: Option C
Constructor is called either implicitly or explicitly, whereas destructor is always called implicitly.
[C].
Destructor is always called explicitly.
[D].
Constructor and destructor functions are not called at all as they are always inline.
Answer: Option B
Explanation:
No answer description available for this question.
Answer: Option C
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.
#include
#include
class IndiaBix
{
char str[50];
char tmp[50];
public:
IndiaBix(char *s)
{
strcpy(str, s);
}
int BixFunction()
{
int i = 0, j = 0;
while(*(str + i))
{
if(*(str + i++) == ' ')
*(tmp + j++) = *(str + i);
}
*(tmp + j) = 0;
return strlen(tmp);
}
};
int main()
{
char txt[] = "Welcome to IndiaBix.com!";
IndiaBix objBix(txt);
cout<< objBix.BixFunction();
return 0;
}
[A].1
[B].2
[C].24
[D].25
Answer: Option B