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
Answers were Sorted based on User's Feedback
Answer / guest
pass a const reference to Alpha in FillData i.e Ans e)
Is This Answer Correct ? | 16 Yes | 4 No |
What do the header files usually contains?
can output 5 students using one dimensional array
How a new operator differs from the operator new?
Please explain the reference variable in c++?
What are stacks?
What is a flag in c++?
What is c++ try block?
What is the full form of india?
Why would you use pointers in c++?
What is the rule of three?
Define a way other than using the keyword inline to make a function inline?
What is the use of static functions?