C What are the benefits of the base class parent class as a type of derived class

Updated on technology 2024-02-09
6 answers
  1. Anonymous users2024-02-05

    Many classes are derived a lot and take up a lot of resources.

    The best thing about using base classes is that it saves resources and can reduce the occupation of system resources by many redundant functions.

    Illustrate. Car (base class) - Car (derived class) - Car (derived class) Each derived class references some properties and methods of the parent class, and some properties and methods are redundant for the new class, then it occupies resources, so it is good to understand the base class of each class.

  2. Anonymous users2024-02-04

    Inheritance is. One of the three major features of .net, after the child class inherits from the parent class, it can directly use all the methods and properties of the parent class;

    **As follows: using system;

    static void main(string args)Chinese cn = new Chinese();

    Ren Ruiquan";;It doesn't make any practical sense, just to illustrate that a method in the parent class can be called;

    define a class of "people";

    class people.

    Two fields: name and age;

    public string name

    public int age

    public void test()

    Define a "class for Chinese and inherit this class for people."

    class Chinese : 人.

    public void sayhello(string name, int age)

    My name is this year, I am Chinese, I speak Chinese", name, age);

  3. Anonymous users2024-02-03

    Method reuse to enhance usability and reduce volume.

  4. Anonymous users2024-02-02

    The base class is the parent class, and the derived class is the child class.

    You can understand it as a father-son relationship in life, that is, the son inherits all the physical characteristics of the father, but the son also has some characteristics that the father does not have.

    Technically, it means that the child class can inherit and use the properties and methods of the parent class, and it can also have its own properties and methods!

    I don't know if you can understand that?

    Here are some inherited features:

    Inheritance uses inheritance to reduce redundancy and enhance scalability.

    The child class inherits the parent class: (must be is.)

    a) class

    Child Class Name: The name of the parent class.

    If there is a parameterless constructor in the parent class, then the child class implicitly calls the default parameterless constructor base() of the parent class: otherwise, the constructor that calls the parent class with parameters is displayed base(parameter name). Inherited properties.

    Transitivity: A child class can call the properties and methods of the parent class and all parent classes above the parent class: a child class cannot inherit two or more parent classes at the same time.

  5. Anonymous users2024-02-01

    In plain language.

    Cars can be divided into:

    Cars and trucks, etc... So.

    Cars are the base class.

    Cars and trucks are derivatives of cars...

    Professionally speaking. The base class is the parent class.

    Derived classes are subclasses.

    The relationship between the child class and the parent class is.

    The subclass isa parent class, ie.

    The child class must be the parent class.

  6. Anonymous users2024-01-31

    A itself can be used as B, just call the arguments of the parent class directly.

    You can also create a b variable that points to b1 = a;

    Solution 1*(a as b) and rewrite.

    Solution 2*If you want the result to be b and discard the arguments to a, define a reproducible constructor yourself.

    class b

    public b()

    public b(b b) constructor of reproducibility.

    In a self-defined method, when creating an instance of B, copy A with all the parameters that need to be retained.

    b b1 = new b(a);This creates a new object of type B, and the data is copied from A.

    Solution 3*Instead of using inheritance, use a reference that contains a class A containing a b, which is used when called, so that it is type B.

    In short, object-oriented design ideas do not allow children to be transformed into parent classes, and if this is the case, it is better to implement them differently.

Related questions
10 answers2024-02-09

First of all, a Class C has 254 addresses but there is always one as a gateway route, so there can be a maximum of 253 hosts. Then these hosts are public IP addresses. It can be done by setting up a LAN and using one IP. >>>More

3 answers2024-02-09

The file class is used for typical operations such as copying, moving, renaming, creating, opening, deleting, and appending to files. You can also use the file class to get and set file properties or datetime information about file creation, access, and write operations. >>>More

3 answers2024-02-09

3. All include

using namespace std; >>>More

14 answers2024-02-09

Innocent landlord pretty tenant.

Probably the genre should be campus light comedy?! >>>More

11 answers2024-02-09

It's not interesting, it's just that there's these members and methods in this category.