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 #include sstream?
Why cout is used in c++?
What are c++ stream classes?
What are the various access specifiers in c++?
I need to find a specific string between two strings how do I do it?
What happens if a pointer is deleted twice?
Describe the syntax of single inheritance in C++?
Why is c++ not purely object oriented?
what is importance of data sturture in a programming language?
22 Answers L&T, TCS, Wipro,
Does c++ have foreach?
How does a C++ structure differ from a C++ class?
what is the size of a class which contains no member variables but has two objects??? is it 1 or 2??