class Alpha {
public:
char data[10000];
Alpha();
~Alpha();
};
class Beta {
public:
Beta() { n = 0; }
void FillData(Alpha a);
private:
int n;
};
How do you make the above sample code more efficient?
a) If possible, make the constructor for Beta private to
reduce the overhead of public constructors.
b) Change the return type in FillData to int to negate the
implicit return conversion from "int" to "void".
c) Make the destructor for Alpha virtual.
d) Make the constructor for Alpha virtual.
e) Pass a const reference to Alpha in FillData
Answer Posted / guest
pass a const reference to Alpha in FillData i.e Ans e)
| Is This Answer Correct ? | 16 Yes | 4 No |
Post New Answer View All Answers
Define a conversion constructor?
Can we use struct in c++?
Are there interfaces in c++?
Does c++ vector allocate memory?
What is the function to call to turn an ascii string into a long?
Is python written in c or c++?
Explain function overloading
Carry out conversion of one object of user-defined type to another?
How to tokenize a string in c++?
What is static in c++?
Explain what is class definition in c++ ?
What do you mean by inheritance in c++? Explain its types.
What does #define mean in c++?
What are stacks? Give an example where they are useful.
What is void pointer in c++ with example?