26 lines
945 B
C++

#include <iostream>
#include "Employee.h"
#include "Company.h"
int main() {
std::cout << "Aggregation example" << std::endl;
{
std::cout << "----------- nested block 1 begin -----------" << std::endl;
Employee* ptrEmp = new Employee("John");
{
std::cout << "----------- nested block 2 begin -----------" << std::endl;
Company c("SmartCo", ptrEmp);
std::cout << "Employee ";
c.employed();
std::cout << " works for company " << c.toString() << std::endl;
std::cout << "----------- nested block 2 end -----------" << std::endl;
}
std::cout << "Company doesn't exist anymore" << std::endl;
std::cout << "But, employee " << ptrEmp->toString();
std::cout << " still exists!" << std::endl;
std::cout << "----------- nested block 1 end -----------" << std::endl;
delete ptrEmp;
}
return 0;
}