Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Base.h
- #ifndef BASE_H
- #define BASE_H
- #include <vector>
- class Base{
- protected:
- std::vector<int> arr;
- };
- #endif
- //class1.h
- #ifndef CLASS1_H
- #define CLASS1_H
- #include "Base.h"
- #include <vector>
- class class1: protected virtual Base{
- protected:
- void input();
- };
- #endif
- //class2.h
- #ifndef CLASS2_H
- #define CLASS2_H
- #include "Base.h"
- #include <vector>
- class class2: protected virtual Base{
- protected:
- void sort();
- void print(bool is_endl=true);
- };
- #endif
- //class3.h
- #ifndef CLASS3_H
- #define CLASS3_H
- #include "class2.h"
- #include "class1.h"
- #include <vector>
- class class3: private class1,private class2{
- public:
- void call();
- };
- #endif
- //class1.cpp
- #include "class1.h"
- #include <vector>
- #include <iostream>
- using namespace std;
- void class1::input(){
- int s;
- cin>>s;
- arr.resize(s);
- for(int i=0;i<arr.size();i++) cin>>arr[i];
- }
- //class2.cpp
- #include "class2.h"
- #include <vector>
- #include <iostream>
- #include <iomanip>
- #include <algorithm>
- void class2::sort(){
- std::sort(arr.begin(),arr.end());
- }
- void class2::print(bool is_endl){
- for(auto el: arr) std::cout<<std::setw(5)<<el;
- (is_endl)?std::cout<<"\n":std::cout<<"";
- }
- //class3.cpp
- #include "class3.h"
- #include <iostream>
- using std::cout;
- void class3::call(){
- input();
- cout<<"Array dimension: "<<arr.size()<<'\n';
- cout<<"The original array:";
- print();
- sort();
- cout<<"An ordered array:";
- print(0);
- }
- //main.cpp
- #include "class3.h"
- int main()
- {
- class3 c3;
- c3.call();
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement