### 题目描述

MathBook类继承自Book类，Book类中含有私有成员price，MathBook类中增加私有成员difficulty，为MathBook设计display函数输出price和difficulty。

#include <iostream>
using namespace std;
class Book
{
public:
Book(int);
int getprice();
protected:
int price;
};
class MathBook:public Book
{
public:
MathBook(int,int);
int getdifficulty();
void display();
private:
int difficulty;
};
Book::Book(int a)
{
price=a;
}
int Book::getprice()
{
return price;
}
MathBook::MathBook(int a,int b):Book(a)
{
difficulty=b;
}
int MathBook::getdifficulty()
{
return difficulty;
}
void MathBook::display()
{
/*
补充部分
*/
}
int main()
{
int price,difficulty;
cin>>price>>difficulty;
MathBook math(price,difficulty);
math.display();
return 0;
}

price和difficulty

### 输出

price和difficulty（中间以空格分开）

30 4

30 4

### 代码如下

``````
#include <iostream>
using namespace std;
class Book
{
public:
Book(int);
int getprice();
private:
int price;
};
class Math:public Book
{
public:
Math(int,int);
int getdifficulty();
private:
int difficulty;
};
Book::Book(int a)
{
price=a;
}
int Book::getprice()
{
return price;
}
Math::Math(int a,int b):Book(a)
{
difficulty=b;
}
int Math::getdifficulty()
{
return difficulty;
}
void display(Math math)
{    cout<<math.getprice()<<" "<<math.getdifficulty()<<endl;

}
int main()
{
int price,difficulty;
cin>>price>>difficulty;
Math math(price,difficulty);
display(math);
return 0;
}
``````