08_01.cpp

来自「一些C++的课件和实验源代码」· C++ 代码 · 共 39 行

CPP
39
字号
// 08_01.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
using namespace std;

class A{
private:
	int x;
	void f1(){cout << "private function." << endl;}
protected:
	int y;
	void f2(){cout << "protected function." << endl;}
public:
	int z;
	void f3(){cout << "public function." << endl;}
};

class B: public A{
public:
	void test(){
		A a;
		a.x = 10;
		a.y = 10;
		a.z = 10;
		a.f1();
		a.f2();
		a.f3();
	}
};

int main(int argc, char* argv[])
{
	B b;
	b.test();

	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?