刺猬在天冷时围抱取暖,但保持一定距离避|

jinganglang567

园龄:4年5个月粉丝:0关注:20

📂c++
🔖c++
2023-02-18 16:50阅读: 50评论: 0推荐: 1

析构派生类

析构派生类

构造函数不能继承,创建派生类对象时,先执行基类构造函数,再执行派生类构造函数。

析构函数不能继承,而销毁派生类对象时,先执行派生类析构函数,再执行基类析构函数。

派生类的析构函数在执行完后,会自动执行基类的析构函数。

如果手工的调用派生类的析构函数,也会自动调用基类的析构函数。

析构派生类的要点如下:

1)析构派生类对象时,会自动调用基类的析构函数。与构造函数不同的是,在派生类的析构函数中不用显式地调用基类的析构函数,因为每个类只有一个析构函数,编译器知道如何选择,无需程序员干涉。

2)析构函数可以手工调用,如果对象中有堆内存,析构函数中以下代码是必要的:

delete ptr;
ptr=nulllptr;

3)用基类指针指向派生类对象时,delete基类指针调用的是基类的析构函数,不是派生类的,如果希望调用派生类的析构函数,就要把基类的析构函数设置为虚函数。

4)C++编译器对虚析构函数做了特别的处理。

5)对于基类,即使它不需要析构函数,也应该提供一个空虚析构函数。

6)赋值运算符函数不能继承,派生类继承的函数的特征标与基类完全相同,但赋值运算符函数的特征标随类而异,它包含了一个类型为其所属类的形参。

7)友元函数不是类成员,不能继承。

本文作者:jinganglang567

本文链接:https://www.cnblogs.com/tgfoven/p/17133043.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   jinganglang567  阅读(50)  评论(0编辑  收藏  举报
  1. 1 look after you louis tomlinson
  2. 2 just hold on louis tomlinson
  3. 3 i can steven cooper
  4. 4 rock me one direction
  5. 5 just can't let her go one direction
  6. 6 this town Niall Horan
  7. 7 cut in love july
  8. 8 nemo 夜愿
  9. 9 in the end Black Veil Brides
  10. 10 glad you came the wanted
  11. 11 chasing the sun the wanted
  12. 12 TAKE MY HAND simple plan
  13. 13 wish i had an angel 夜愿
just hold on - louis tomlinson
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

作词 : Sasha Alex Sloan/Eric Rosse

作曲 : Steve Aoki/Louis Tomlinson/Sasha Alex Sloan/Nolan Lambroza/Eric Rosse

Wish that you could build a time machine

So you could see

The things no one can see

Feels like you're standing on the edge

Looking at the stars

And wishing you were them

What do you do when a chapter ends?

Do you close the book and never read it again?

Where do you go when your story's done?

You can be who you were or who you'll become

Oooh

If it all goes wrong

Oooh

Darling just hold on

The sun goes down and it comes back up

The world it turns no matter what

Oooh

If it all goes wrong

Darling just hold on

Oooh

Darling just hold on

Oooh

It's not over until it's all been said

It's not over until your dying breath

So what do you want them to say when you're gone?

That you gave up or that you kept going on?

What do you do when a chapter ends?

Do you close the book and never read it again?

Where do you go when your story's done?

You can be who you were or who you'll become

Oooh

If it all goes wrong

Oooh

Darling just hold on

The sun goes down and it comes back up

The world it turns no matter what

Oooh

If it all goes wrong

Darling just hold on

Oooh

Darling just hold on

Oooh

Oooh

If it all goes wrong

Oooh

Darling just hold on

Oooh

If it all goes wrong

Darling just hold on

点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起