Fragile class problem is a problem of object oriented programing. Suppose we have two class first class is the parent and second class is the child class. In the child class we have inherited the parent class and both have two overloaded function means have same method name.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication8 { classProgram { staticvoid Main(string[] args) { Child obj = newChild(); int i = 100; obj.NumberNumeric(i); double j = 100; obj.NumberNumeric(j); } } publicclassParent { publicvirtualvoid NumberNumeric(int i) { Console.WriteLine("Parent Number Function"); } } publicclassChild : Parent { publicvoid NumberNumeric(double i) { Console.WriteLine("Child Number Function"); } } }
When we run this application we get unexpected result
To overcome this problem we can make the class sealed. In the above example I have make parent class and child and in the child I have extended parent class then in the main make the instance of child.
Liked By
Write Answer
What is Fragile class problem.?
Join MindStick Community
You have need login or register for voting of answers or question.
Royce Roy
25-Feb-2017Fragile class problem is a problem of object oriented programing. Suppose we have two class first class is the parent and second class is the child class. In the child class we have inherited the parent class and both have two overloaded function means have same method name.
When we run this application we get unexpected result
To overcome this problem we can make the class sealed. In the above example I have make parent class and child and in the child I have extended parent class then in the main make the instance of child.