Orientation Object in C # - Inheritance [duplicate]

-3

Regarding Orientação Objeto in C# , I have the following doubt:

What is the difference between inheritance of code reuse , constructor , abstract methods superclasses and subclasses ?

It does not refer to the duplicate, as I do not want the definition of Inheritance in object oriented. The question is different. Examples would be of help .

    
asked by anonymous 31.08.2017 / 14:32

1 answer

1

The meanings of each concept have been perfectly explained in this question: Meaning of terminology : "Object oriented"

But as you asked for some examples of how to implement, follow a very simple code with some of the concepts mentioned above

#region Classe Abstrata
public abstract class Classe
{
    #region Método Abstrato
    public abstract void tratarValor(double valor);
    #endregion
}
#endregion

#region Classe
public class ClassePai
{       
    #region Construtor
    public ClasseFilha()
    {
        Console.Write("Classe Pai Cconstruida");
    }
    #endregion

    #region Sobrecarga de método
    public void imprimirCumprimento()
    {
        Console.Write("Olá!");
    }

    public void imprimirCumprimento(String nome)
    {
        Console.Write("Olá " + nome);
    }
    #endregion  

    public void imprimirIdentificacao()
    {
        Console.Write("Eu sou a classe Pai");
    }   
}
#endregion 

#region SubClasse
public class ClasseFilha
{   
    #region Construtor          
    private int variavelQualquer;

    public ClasseFilha(int variavelQualquer)
    {
        this.variavelQualquer = variavelQualquer;
    }
    #endregion

    #region Encapsultamento
    private String nomePai;

    public void setNomePai(String nomePai)
    {
        this.nomePai = nomePai;
    }

    public String getNomePai()
    {
        return this.nomePai;
    }
    #endregion

    #region Associação de Classes
    ClasseAssociacao classeAssociada = new ClasseAssociacao();
    #endregion

    #region Sobrescrita de método
    public override void imprimirIdentificacao()
    {
        Console.Write("Eu sou a classe Filha");
    }
    #endregion
}
#endregion

public class ClasseAssociacao
{
    String assosiacao = "Nada";
}
  

As I remember some more concepts I will implement   in the example

    
31.08.2017 / 15:50