当前位置:网站首页>Interesting article sharing: what is the difference between C language and C + +, C?

Interesting article sharing: what is the difference between C language and C + +, C?

2020-11-08 16:34:40 Three ah three water

Mission :

Put the elephant in the refrigerator .

 

C Language :

C Language is an extremely cold person , So the answers are cold :

I : Hello C Language , I want to put the elephant in the refrigerator , Can you do it for me ?

C: good

I : So what are we going to do ?

C: guess

I : forehead ... Should we create an elephant first ?

C: yes

I : How to create ?

C: guess

I had to go through the documents , Oh ,malloc A piece of memory .

I : well , I use malloc, How about applying for a space for elephants ?

C: good

I : forehead ... How do elephants make it ?

C: guess

I ... I went to see the structure of the elephant

I : ok ... I defined an elephant data structure , What to do next ?

C: guess

I have a feeling I can't say ...

I : Oh, ok , I created a refrigerator , The steps should be similar to the elephant .

C: Um.

I looked through the structure of the refrigerator , And then defined a refrigerator of struct.

I : Okay , The refrigerator was constructed , How to put it ?

C: hum

I ... In silence Stack Overflow On the input " How to put an elephant in the refrigerator C".

I : Finally, the answer is found , Define a method , Put the elephant's trunk in 、 Put your eyes in 、 Put your ears in .OK, It's all in .C, You can output it and have a look .

C: Scalding, scalding, scalding, scalding

I : Ha ha ha ha C You're not so cold at last

...

I : Ah , Why don't you talk ?C? Do you have a fever ?

Pour a basin of water immediately .

end .

Xiaobian recommends a study C Language /C++ Learning skirt of 【  712,284,705】, Whether you are Daniel or Xiaobai , If you want to change your career or join it, you can learn about it and learn from it together ! There are development tools in the skirt , A lot of dry goods and technical information sharing !

 

C++:

C++ It's a knowledgeable child , Relatively young , It's not that cold .

I :C acutely , Shall we put the elephant in the refrigerator ?

C++: roll

It's not very cold ?

I : Well, I was wrong , dear C++, Let's put the elephant in the refrigerator .

C++: Good mamda , The data types of elephants have been defined , Refrigerators have been defined , You need to construct one each .

I : well .

So I looked through the document and found out that new To construct the

I :OK, dear C++, I want to build an elephant .

C++: well , There are ways to build elephants 13 individual , Which one would you like to choose ?

I ...

I : Let me introduce you .

C++:OK, First, you can construct on the stack , The advantage of this is that it can facilitate resource management , And the grammar is better , You can use RAII, If you don't know something RAII, You can go to cppreference Check it up , Of course, you can also build on the heap , You can build a big, big elephant , also .......

A month later ,C++ It's over . I'm full of whiskers, too ... After shaving, go on working

I : well ,C++, I'll build an elephant on top of the stack .

C++: You don't love me .

I :???

C++: You didn't even say “ dear ”.

I ...

I : ok , dear C++, I want to make an elephant simple .

C++: Okay , You can choose whether to build an African elephant or an American elephant or an Antarctic elephant , You can set the skin color of the elephant , You can set the size of the elephant's butt , The sex and sexual orientation of the elephant. What do you want ......

I : I just want a simple one , Default is good .

C++: well , Constructed a , You can choose how to initialize it , Yes 13 Initialization methods , The latest unified initialization is recommended .

I ...

I : Unified initialization

C++: well , We can build refrigerators .

I : good ...

After a month of choice , Finally, the refrigerator was constructed .

C++: well , The refrigerator provides addElephant Method , It can be used directly .

I : Wow, that's great , well , I use this method .

C++: This method provides multiple overloads , You can copy , Move , You can also forward it directly , Save on building an elephant before moving into the refrigerator .

I :... Why didn't you say

C++: Why didn't you ask .

I : Just use the mobile one .

C++:OK, Please use std::move Turn the constructed elephant into a right-hand reference .

I'm a face of meng , But do it .

I : Okay

C++:OK, It's in the fridge , Very fast .

All of a sudden

C++: Wrong report... Wrong report , Molecules and atoms are not convertible types , There is no relationship between the giant panda and Edison + Operators, etc 1556 Item error .

I .........

I : Look for information online , Just look at the last line , OK, look at it . Um. , It looks like number one 31 There's a mistake , What is the mistake ? I didn't make myself clear when I reported the wrong information . Make any changes . compile , function .

C++: well , It's hip circumference 12 rice , The left arm is long 13 rice , The right arm is long 14 rice , Like male elephants , No marriage, no children , It's good to be tutored since childhood , The African female elephant, who is familiar with the four books and five classics, puts orange in it , Fifty meters high , Sixty meters wide , Three hundred meters thick , It's three hundred degrees below zero , The brand of refrigerant is Huche brand , Rated voltage 220V In the refrigerator .

I ... A long sigh of relief .


 

C#:

I : I want to put the elephant in the refrigerator .

C#: Good master , My dad, Microsoft, has written elephants , Also wrote the refrigerator class , You only need new Just a moment .

I :OK,new Okay , Put it in the refrigerator .

C#: well , Has been put in , Using the expansion method of refrigerator addElephant<>() Method .

I : Um. , You did a good job , Can you make it a little faster , just C++ It's very fast .

C#: For your safety , You can't .

I : forehead ... I'd like to adjust the size of the elephant's ears .

C#: I'm sorry , It can't be adjusted . You can set the shape of the elephant's ear , Many ear shapes have been defined for you , You can also adjust the skin color of the elephant , Many skin colors have been defined for you .

I : Forget it. It's out of tune , be it so .

C#: well . If you need speed , Or you need to grasp every detail of the elephant , You can go and see my brother ,C++/CLR, He can complete the functions you have proposed . You can also bring him to me , We can work together . You can also C++ The finished work is exported to binary form , I can use it directly .

I : Well, thank you , A: no, no .

C#: well , I wish you a happy life .

Click me to enter the learning base through train

 

 

版权声明
本文为[Three ah three water]所创,转载请带上原文链接,感谢