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
What is a hashmap c++?
Explain the use of virtual destructor?
Why is it necessary to use a reference in the argument to the copy constructor?
Difference between inline functions and macros?
What are destructors?
Explain terminate() function?
What is c++ w3school?
Can class objects be passed as function arguments?
When must you use a pointer rather than a reference?
What is fixed in c++?
What is linked list in c++?
What is the first name of c++?
How can we read/write Structures from/to data files?
Explain how overloading takes place in c++?
Discussion on error handling of C++ .