오늘은 추상화에 대해 검색하고 있었고, 난이 예제를 가지고 ....이 프로그램은 추상화의 개념을 구현하고도 정교한하시기 바랍니다 어떻게이 인 data abstraction를 호출 할 필요가이 프로그램은 추상화의 개념을 어떻게 구현합니까?
#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;
}
당신은 "추상 개념"을 구현한다고 주장하고 그것에 대해 아무 말도하지 않은 프로그램을 발견 했습니까? 어디서 찾았 니? 처음에 언급되지 않았다면 "추상 개념"을 구현한다는 것을 어떻게 알 수 있습니까? –
여기에 소스입니다 [링크] http://www.tutorialspoint.com/cplusplus/cpp_data_abstraction.htm [링크] –
예제 앞에 전체 텍스트 섹션이있는 것 같습니다. 어떤 정보를 놓치거나 이해하지 못합니까? –