Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm> // for copy
- #include <iterator> // for ostream_iterator
- #include <vector>
- #include <functional>
- class Employee {
- public:
- Employee(const std::string _name, const std::string _last, const int _sal):
- name(_name),
- lastname(_last),
- salary(_sal ) {}
- friend std::ostream& operator<<(std::ostream&os, const Employee& obj) {
- return os << obj.name << " "<< obj.salary;
- }
- private:
- std::string name;
- std::string lastname;
- int salary;
- };
- int main()
- {
- /* Set up vector to hold some number */
- std::vector<int> col{ 23, 23, 37, 42, 23, 23, 37 };
- /* Set up vector to hold chars a-z */
- std::vector<char> path;
- for (int ch = 'a'; ch <= 'z'; ++ch)
- path.push_back(ch);
- /* Set up vector to hold employer detail */
- std::vector<Employee> staff {
- {"Murrary", "Steve", 1000 },
- {"Dave", "Ark", 2000 },
- {"Kate", "Greg", 2000 },
- {"John", "Smith", 1000 },
- {"Jack", "Cho", 2000 }
- };
- std::copy(col.begin(), col.end(), std::ostream_iterator<int>(std::cout, " "));
- std::copy(path.begin(), path.end(), std::ostream_iterator<char>(std::cout, "\t"));
- std::copy(staff.begin(), staff.end(), std::ostream_iterator<Employee>( std::cout, "\n"));
- return 0;
- }
Add Comment
Please, Sign In to add comment