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 is pure virtual function?
Can you use the function fprintf() to display the output on the screen?
What is the difference between global variables and local variable
How to tokenize a string in c++?
How to reduce a final size of executable?
What is the use of volatile keyword in c++? Give an example.
What does n mean in c++?
Is c++ a good first language to learn?
Explain the register storage classes in c++.
Comment on assignment operator in c++.
What is array in c++ example?
What is a vector c++?