Do you know the problem with overriding functions?



Do you know the problem with overriding functions?..

Answer / Vivek Bhardwaj

Overriding functions can lead to unintended behavior if not implemented properly. One common issue is that derived class objects may behave unexpectedly when used in a context where they should be treated as base class objects. Additionally, changing the behavior of an inherited function can break existing code that relies on the original functionality.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

what is the use of Namespace in c++.

3 Answers  


Explain RAII (Resource Acquisition Is Initialization).

3 Answers  


Which function cannot be overloaded c++?

1 Answers  


What is RAII (Resource Acquisition Is Initialization)?

1 Answers  


What are the storage qualifiers?

1 Answers  


Why c++ is faster than java?

1 Answers  


Why do we use iterators?

1 Answers  


What is difference c and c++?

1 Answers  


What is fflush c++?

1 Answers  


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

2 Answers   Quark,


Find out the bug in this code,because of that this code will not compile....... #include <iostream> #include <new> #include <cstring> using namespace std; class balance { double cur_bal; char name[80]; public: balance(double n, char *s) { cur_bal = n; strcpy(name, s); } ~balance() { cout << "Destructing "; cout << name << "\n"; } void set(double n, char *s) { cur_bal = n; strcpy(name, s); } void get_bal(double &n, char *s) { n = cur_bal; strcpy(s, name); } }; int main() { balance *p; char s[80]; double n; int i; try { p = new balance [3]; // allocate entire array } catch (bad_alloc xa) { cout << "Allocation Failure\n"; return 1; }

2 Answers   Impetus,


What is the function to call to turn an ascii string into a long?

1 Answers  


Categories