> For the complete documentation index, see [llms.txt](https://eece.gitbook.io/mist-innovation-club-flutter-course-1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eece.gitbook.io/mist-innovation-club-flutter-course-1/dart-fundamentals-1/inheritance/method-overriding.md).

# Method Overriding

{% embed url="<https://youtu.be/2cAbggyzNJo>" %}

{% hint style="success" %}
When a *Child class* redefines the method of its *Parent class* then it is called Method Overriding
{% endhint %}

{% hint style="success" %}
Overriding is done so that a *child class* can give its own implementation to the method which is already provided by the *parent class*.
{% endhint %}

```dart
void main() {
  
  
  // Method overidding 

  var manager1 = Manager();
  
  
  manager1.id =1;
  manager1.firstname="John";
  manager1.lastname="Doe";
  manager1.dayworked=30;
  
  manager1.project ="Alpha";
  
  print(manager1.salary(20));

  
  
  
  
}

class Employee {
  int id;
  int dayworked;
  String firstname;
  String lastname;

  String fullname() {
    return this.firstname + " " + this.lastname;
  }

  int salary(int perDaywage) {
    return (this.dayworked * perDaywage);
  }
}




// Manager Class 


class Manager extends Employee {
  
  
  //property 
   String project;
 
  
  //Method 
  
  String manageproject(){
    
    return "Managing project " + " " + this.project; 
  }
  
  
   int salary(int perDaywage) {
    return ((this.dayworked * perDaywage)+30);
  }
  
  
}



```

{% hint style="danger" %}
The ***number*** and ***data type*** of function’s argument ***must match*** while overriding the method
{% endhint %}

![](/files/-MDmjuPtprnySUA-CHrm)

Here in the child class , the return type and the  argument datatype of the method is changed from  "int" to "double" , so the compiler shows an error&#x20;

You can visualise method overriding like below -  &#x20;

![](/files/-MDmsvn14mtyygzYHjJt)
