Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:面向对象技术

Posted by heimengnan at 2009-08-25 02:51:38 on Problem 1000
In Reply To:面向对象技术 Posted by:charmant at 2005-10-28 23:02:39
没有封装性啊 应该尽量用private的!
这个是我的代码~嘿嘿
#include<iostream>
using namespace std;
class Object_Oriented
{
	private:
		int sum;
		int a;
		int b;
	public:
		void input()
		{
			cin>>a>>b;
		}
		void plus()
		{
			sum=a+b;
		}
		void output()
		{
			cout<<sum<<endl;
		}
}object;
int main()
{
	object.input();
	object.plus();
	object.output();
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator