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



class Alpha { public: char data[10000]; Alpha(); ~Alpha(); }; class Beta { ..

Answer / guest

pass a const reference to Alpha in FillData i.e Ans e)

Is This Answer Correct ?    16 Yes 4 No

class Alpha { public: char data[10000]; Alpha(); ~Alpha(); }; class Beta { ..

Answer / mpoleg

c)
all other options are not valid c++

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More C++ General Interview Questions

Explain deep copy and a shallow copy?

0 Answers  


What is late binding c++?

0 Answers  


What is Name Decoration?

2 Answers   Lucent,


Explain the concept of memory leak?

0 Answers  


What does flush do c++?

0 Answers  






What's the most powerful programming language?

0 Answers  


Explain container class.

0 Answers  


Check for Balanced Parentheses using Stack?

1 Answers  


How long it will take to learn c++?

0 Answers  


How the virtual functions maintain the call up?

0 Answers  


What are smart pointers?

0 Answers  


What is a concrete class?

1 Answers  


Categories