16,550
社区成员
发帖
与我相关
我的任务
分享// private.cpp : 定义控制台应用程序的入口点。
//私有成员函数只能在类里面访问
#include "stdafx.h"
#include <iostream>
using namespace std;
class A
{
public:
A(int a,int b){x=a;y=b;}
//public:
private: void output2()
{
cout << x <<endl<<y <<endl;
}
private:
int x;
int y;
};
int _tmain(int argc, _TCHAR* argv[])
{
A a(3,6);
a.output2();
system("pause");
return 0;
}