今天,我正在寻找关于抽象和我得到这个例子....这个方案是如何实现的抽象的概念,也请您详细说明什么是抽象的C++该程序如何实现抽象的概念?
#include <iostream>
using namespace std;
class Adder{
public:
// constructor
Adder(int i = 0)
{
total = i;
}
// interface to outside world
void addNum(int number)
{
total += number;
}
// interface to outside world
int getTotal()
{
return total;
};
private:
// hidden data from outside world
int total;
};
int main()
{
Adder a;
a.addNum(10);
a.addNum(20);
a.addNum(30);
cout << "Total " << a.getTotal() <<endl;
return 0;
}
你找到了一个声称实现“抽象概念”的程序,但没有提到它的任何内容?你在哪里找到它?你怎么知道它实现了“抽象的概念”,如果没有提到这一点呢? – 2013-02-17 14:48:00
这里是源代码[link] http://www.tutorialspoint.com/cplusplus/cpp_data_abstraction.htm [链接] – 2013-02-17 14:49:35
它看起来像是整个案例之前的一段文字。你有什么信息想念或不明白? – 2013-02-17 14:50:50