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 friend class in c++ with example?
What is a 'pure' virtual function and what's its use?
Write bites in Turbo c++ Header ("Include") Files.
what is pre-processor in C++?
How do you add an element to a set in c++?
What is the difference between a copy constructor and an overloaded assignment operator?
4 Answers Belzabar, Citrix, Microsoft, Wipro,
What is private, public and protected inheritance?
Is it possible for the objects to read and write themselves?
Explain explicit container.
Explain about vectors in c ++?
If a base class declares a function to be virtual, and a derived class does not use the term virtual when overriding that class, is it still virtual when inherited by a third-generation class?
Explain "passing by value", "passing by pointer" and "passing by reference" ?