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
Answer Posted / guest
pass a const reference to Alpha in FillData i.e Ans e)
| Is This Answer Correct ? | 16 Yes | 4 No |
Post New Answer View All Answers
What are manipulators in c++ with example?
Write my own zero-argument manipulator that should work same as hex?
Why is c++ a mid-level programming language?
Explain what are the sizes and ranges of the basic c++ data types?
Is empty stack c++?
Can a program run without main in c++?
Explain data encapsulation?
Can I learn c++ without c?
How can you prevent accessing of the private parts of my class by other programmers (violating encapsulation)?
What is the difference between an external iterator and an internal iterator? Describe an advantage of the external iterator.
Define a constructor - what it is and how it might be called (2 methods)?
What size is allocated to the union variable?
Why c++ is better than c language?
Explain what is class definition in c++ ?
What is oops in c++?