class Car와 class Everything을 template을 이용하여 정의하시오. class Car는 다음 2가지 method를 제공 - method addName(arg ) : 인수를 object 안에 저장 - vector< > getSortedNames( ) : 저장된 데이터를 오름차순으로 정렬한 vector를 반환 class Everything 은 Car object 3개를 생성자의 인수로 받고, method printAll( )은 생성자에 주어진 인수의 순서대로 각 object에서 값을 하나씩 가져와서 공백 1개로 구분하여 출력. 예를 들어, Car c1 = {ccc, bbb, aaa} Car c2 = {3, 2} Car c3 = {'a'} 이고, Everything (c1, c2, c3)로 생성했다면, c1, c2, c3의 데이터가 각각 오름차순으로 정렬된 형태로, 하나씩 순서대로 출력하되, 만약 출력할 것이 없으면 skip. printAll() ---> aaa 2 a bbb 3 ccc Everything (c3, c2, c1)로 생성했다면, printAll() ---> a 2 aaa 3 bbb ccc
/* 필요한 헤더파일을 include하세요. */ using namespace std; /* class Car와 class Everything을 template을 이용하여 정의하시오. */ //----------------------------------------------------------- // 아래 부분은 절대 수정하지 마시오. //----------------------------------------------------------- int main() { Car<string> c; string name; while (true) { getline(cin, name); if (name == "END") { break; } else { c.addName(name); } } Car<int> d; int n; while (true) { cin >> n; if (n == 999) { break; } else { d.addName(n); } } Car<char> e; char _c; while (true) { cin >> _c; if (_c == '`') { break; } else { e.addName(_c); } } Everything<vector<string>, vector<int>, vector<char>> everything_1(c.getSortedNames(), d.getSortedNames(), e.getSortedNames()); everything_1.printAll(); cout << '\n'; Everything<vector<int>, vector<char>, vector<string>> everything_2(d.getSortedNames(), e.getSortedNames(), c.getSortedNames()); everything_2.printAll(); cout << '\n'; Everything<vector<char>, vector<string>, vector<int>> everything_3(e.getSortedNames(), c.getSortedNames(), d.getSortedNames()); everything_3.printAll(); cout << '\n'; return 0; }