Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <sstream>
- #include <cstdlib>
- #include <iostream>
- #include <clocale>
- using namespace std;
- class matrix{
- public:
- int x;
- int y;
- matrix(int x, int y){
- this->x = x;
- this->y = y;
- }
- virtual int get_resolution(){
- return (x*y);
- }
- void print()
- {
- cout << x <<" "<< y <<" "<< get_resolution()<<endl;
- }
- virtual ~matrix() {}
- };
- class processor{
- public:
- float chas;
- string arch;
- string name;
- processor(float chas, string arch, string name){
- this->chas = chas;
- this->arch = arch;
- this->name = name;
- }
- virtual void set(float chas2, string arch2, string name2){
- chas = chas2;
- arch = arch2;
- name = name2;
- }
- virtual string print()
- {
- cout<<"Частота: "<<chas<<"\n"
- <<"Архитектура: "<<arch<<"\n"
- <<"Имя: "<<name<<endl;
- return 0;
- }
- virtual ~processor() {}
- };
- class phone: public processor, public matrix{
- public:
- float memory;
- float ves;
- string model_name;
- phone(float memory, float ves, string model_name, int x, int y, float chas, string arch, string name):processor(chas, arch, name),matrix(x,y){
- this->memory = memory;
- this->ves = ves;
- this->model_name = model_name;
- }
- virtual string print()
- {
- processor::print();
- matrix::print();
- cout<<"Память: "<<memory<<"\n"
- <<"Вес: "<<ves<<"\n"
- <<"Имя: "<<model_name<<endl;
- return 0;
- }
- virtual ~phone() {}
- };
- int main(int argc, char* argv[])
- {
- setlocale (LC_ALL, "Russian");
- phone* mobile = new phone(2,4,"iphone",34,23,23,"ARH","Apple");
- mobile->print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement