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 the first name of c++?
What is a container class? What are the types of container classes?
Describe friend function & its advantages.
What is design pattern?
Write the program for fibonacci in c++?
Which bit wise operator is suitable for putting on a particular bit in a number?
what is Loop function? What are different types of Loops?
what is a class? Explain with an example.
What happens if a pointer is deleted twice?
Explain method of creating object in C++ ?
Is overriding possible in c++?
What are register variables?