[1.1] c++のプログラムのコンパイルを通したいのです。コンパイルの通らない理由をご教授願います。
[1.2] 下記
[1.3] コンパイルが通りません。
[2] 環境
[2.1] OS : Windows10
[2.2] コンパイラ名 : VC++ 2008EE
[3] その他
・Cをある程度知っているC++言語の初心
/*
* simpleclass01.cpp
*/
#include <iostream>
using namespace std;
Class MyClass
{
private:
int a;
public:
int b;
int sat_a();
int show();
};
int MyClass::show_a()
{
cout << "a > ";
cin >> a;
return 0;
}
int MyClass::set_a()
{
cout << "a = " << a << endl;
return 0;
}
int main()
{
MyClass mc;
// b は、公開メンバなので直接値を代入出来る
mc.b = 100;
cout << "b = " << mc.b << endl; // b の値を確認
// 次の行は、エラー(非公開部にはアクセス不可)
// mc.a = 200; // エラー因
// a に値を代入するには、公開メンバの set_a関数を利用する。
mc.set_a();
// a に値を確認するには、公開メンバの show_a関数を利用する。
mc.show_a();
return 0;
}