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


Please Help Members By Posting Answers For Below Questions

What is a hashmap c++?

574


Explain the use of virtual destructor?

626


Why is it necessary to use a reference in the argument to the copy constructor?

637


Difference between inline functions and macros?

600


What are destructors?

577






Explain terminate() function?

596


What is c++ w3school?

636


Can class objects be passed as function arguments?

609


When must you use a pointer rather than a reference?

608


What is fixed in c++?

588


What is linked list in c++?

695


What is the first name of c++?

567


How can we read/write Structures from/to data files?

619


Explain how overloading takes place in c++?

577


Discussion on error handling of C++ .

649