---
title: "c++继承"
author: "Sweblish"
date: "2012-03-07T22:10:30Z"
tags: ["C++"]
categories: ["编程语言"]
slug: "c"
draft: false
lastmod: "2012-03-07T22:10:30Z"
id: 1444465
url: "https://sweblish.iteye.com/blog/1444465"
---

继承分为： 私有继承：继承过来的内容编程私有的 protected继承：继承过来的属性和方法变成protected类型的 public继承：继承过来的属性和方法变成public类型的 #include using namespace std; class A{ public: int a; public: ~A(){ cout&lt;&lt;"~A"&lt;a = a; } }; int main() { cout &lt;&lt; "Hello world!" &lt;&lt; endl; B b; b.set(100); b.get(); // b.gett(); // cout&lt;