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
Can we use this pointer in a class specific, operator-overloading function for new operator?
How does java differ from c and c++?
What new()is different from malloc()?
What is the difference between the functions rand(), random(), srand() and randomize()?
How can I improve my c++ skills?
write a c++ program to create class student having datamember name,Roll_no,age,and branch intilcization all the member using constructor print the all the details on the screen.
What is a stack? How it can be implemented?
What is difference between n and endl in c++?
What do you mean by ‘void’ return type?
What is setf in c++?
What is a character in c++?
Can constructor be private in c++?
Do inline functions improve performance?
What is a memory leak c++?
What is a hash function c++?