YTU-OJ-Problem B:A改誤題--植物と花
2140 ワード
Problem B:A改誤題--植物と花
Time Limit: 1 Sec
Memory Limit: 128 MB
Submit: 205
Solved: 135
[ Submit][ Status][ Web Board]
Description
注意:この問題は修正部分としてマークされたコードを提出するだけです.C++で提出してください.
植物類には属性id(番号)とname(名称)があり、花類は植物類から私有的に継承され、新しい属性Florescence(花期)が追加される.
#include #include #include using namespace std; class Plant { private: int id; string name; public: Plant(int id,string name):id(id),name(name) {} void show() { cout<>id>>name>>Florescence; Flower f1(id,name,Florescence); f1.show(); return 0; }
Input
植物の番号、名前、花期
Output
この植物の番号、名前、花期
Sample Input
Sample Output
HINT
Time Limit: 1 Sec
Memory Limit: 128 MB
Submit: 205
Solved: 135
[ Submit][ Status][ Web Board]
Description
注意:この問題は修正部分としてマークされたコードを提出するだけです.C++で提出してください.
植物類には属性id(番号)とname(名称)があり、花類は植物類から私有的に継承され、新しい属性Florescence(花期)が追加される.
#include
Input
植物の番号、名前、花期
Output
この植物の番号、名前、花期
Sample Input
5021 Peony 5
Sample Output
5021 Peony 5
HINT
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
class Plant
{
private:
int id;
string name;
public:
Plant(int id,string name):id(id),name(name) {}
void show()
{
cout<<id<<" "<<name;
}
};
class Flower:private Plant
{
private:
int Florescence; //
public:
Flower(int id,string name,int Florescence):Plant(id,name),Florescence(Florescence) {}
void show()
{
/***** ******/
Plant::show();
cout<<" "<<Florescence<<endl;
/***** *****/
}
};
int main()
{
int id,Florescence;
string name;
cin>>id>>name>>Florescence;
Flower f1(id,name,Florescence);
f1.show();
return 0;
}