Home > Net >  The great spirit on the c #, head hurts
The great spirit on the c #, head hurts

Time:10-03

Great god explain example 9.13, that's don't understand, for no reason

CodePudding user response:

Explanation is no use, best to play a practical procedure, himself running to see
A look not to understand, but don't look at this and see

CodePudding user response:

To be honest I don't know what is the purpose of this book such a problem? Subclass inherits parent class performs the inside of the parent class method, but also don't like ah, otherwise it is not necessary to do so complicated! Tell the reader program can also write like this? Not necessary, readability is not so high!

CodePudding user response:

Did this topic out of trouble, the explanation is in place,

But the only problem is that the sample program, don't know which nerve is wrong, the author
Why do you want to put the Program as a base class of these classes,

CodePudding user response:


Give you a simple example

CodePudding user response:

This is called polymorphism, in the method the

Part 2 interface form

Part 1 is a class form

Override, the new method

CodePudding user response:

According to specific application scenarios under entangled with abstract classes, virtual method and abstract methods can be rewritten or cover, this even polymorphism,

CodePudding user response:

Polymorphism is:
Animals is a base class, have to eat this way,
But eating chicken, dog eating specific is not the same (chickens without teeth can only swallow, dogs can have teeth chew)
If there are both chicken and dog, always can't eat, called again to call the dog
In a word: eat
So chickens, dogs are just open to eat, you don't need to care about dogs or chicken, also don't need to care about how to eat, even if again many animals don't have to worry about,

CodePudding user response:

reference caozhy reply: 3/f
did this topic out of trouble, the explanation is in place,

But the only problem is that the sample program, don't know which nerve is wrong, the author
Why do you want to put the Program as a base class of these classes,


C # programmers seem to and don't like the Main into a single static class, this example is to put the business code in the Program, and the example is the Main force to other business code, just to write less a class,

CodePudding user response:

The things, one is less code book, read philosophy

Polymorphic understand -- -- -- -- -- -- -- -- the understanding about the abortion

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

A joke, but the meaning has been "sound agree with different" stand in the Angle of "voice" is in fact similar sounds, different meanings,

OOP is itself with "philosophy" hung with deep, discussed is how to abstract the world, how to express the world,

We can define a real "world", also can inherit the "world" turned him into Japan's second yuan, also can put him into the universe "through", "DC universe" right,


This is to express the meaning of your book,

The program===========the world

{
Retrun "to describe what he is like"

}

Diffuse wei universe: the world
{
Retrun "to describe what he is, he generally keep pace with the world, as have the earth, human, mountains, rivers, the planet, but he has a super hero, this world have parallel universe, have destroyed barings"
}

CodePudding user response:

The elder brother of the panda, 666

CodePudding user response:

Japan's second yuan: the world
{
Retrun the world people are "long strange, most of the time is the plane of kind of the human body, the super big eyes, a yellow or silver hair, the clothes are very few, the sound is strange," bone QingQi variety orders are
}

CodePudding user response:

11 references wanghui0380 response:
this thing, is to see less code book, read philosophy

Polymorphic understand -- -- -- -- -- -- -- -- the understanding about the abortion

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

A joke, but the meaning has been "sound agree with different" stand in the Angle of "voice" is in fact similar sounds, different meanings,

OOP is itself with "philosophy" hung with deep, discussed is how to abstract the world, how to express the world,

We can define a real "world", also can inherit the "world" turned him into Japan's second yuan, also can put him into the universe "through", "DC universe" right,


This is to express the meaning of your book,

The program===========the world

{
Retrun "to describe what he is like"

}

Diffuse wei universe: the world
{
Retrun "to describe what he is, he generally keep pace with the world, as have the earth, human, mountains, rivers, the planet, but he has a super hero, this world have parallel universe, have destroyed barings"
}

admire

CodePudding user response:

C beginners should start learning,

CodePudding user response:

According to the example is the best approach, write one more time

CodePudding user response:

You need to understand the characteristics of object-oriented programming, what is called polymorphism, and what inheritance

CodePudding user response:

Understanding of polymorphism, my own summary, provide a reference to you:

Polymorphism generally to the following conditions:
One is A continued relationship: B: A
Second, there are the same as the parent class name: a. the virtual (), A virtual a1 () method, B has A new A (), override a1 () method
3 it is the parent class to subclass an instance of the - & gt; B=new b ()

When instance b calls the subclasses of a method, the new don't support polymorphism, inheritance so only and then executes a method of the parent,
When case b calls the subclasses of a1 method, override supports polymorphism, which in turn will perform a subclass of a1 method,

CodePudding user response:

Polymorphic points of two kinds:

1: rewrite the methods of the parent in subclasses override method when adding new
2: the same method of different parameter or data type, at the time of call back according to your which is what you call methods to estimate the parameters of

Give I feel the biggest advantage is to won't have too many methods to take hutchison name, or very convenient

Ps: I am a freshman, is to learn in school. Net, such as defective please forgive me,

CodePudding user response:

According to the example is the best approach, write one more time

CodePudding user response:

B stands a technology communication workshop introduction to c #, speak well, you can go and see

CodePudding user response:

See 3 side actually technical books, generally, is totally not skull pain,,,
The first time can read called genius,
The second time can read called talent
Third time can understand the call? Only
I am a third time,,,, ha, ha, ha

CodePudding user response:

Take computer out to knock, run, debug, you will understand, a lot of things have to your own feeling, understanding, language is not three or two explain clearly,
  •  Tags:  
  • C#
  • Related