consolidate all repos to one for archive

This commit is contained in:
2025-01-28 13:46:42 +01:00
commit a6610fbc7a
5350 changed files with 2705721 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
#ifndef EXAMPLE11_HOUSE_H
#define EXAMPLE11_HOUSE_H
#include <iostream>
#include "Room.h"
class House {
private:
std::string name;
Room kitchen, livingRoom, bedroom; //composition
public:
House(std::string name) : name(name), kitchen("Kitchen1"), livingRoom("living room 1"),
bedroom("TV bedroom") {
std::cout << "House::constructor" << std::endl;
}
virtual ~House() {
std::cout << "House::destructor" << std::endl;
}
virtual void print() const {
std::cout << "House name: " << name << std::endl;
kitchen.print();
livingRoom.print();
bedroom.print();
}
};
#endif //EXAMPLE11_HOUSE_H

View File

@@ -0,0 +1,21 @@
#ifndef EXAMPLE11_ROOM_H
#define EXAMPLE11_ROOM_H
#include <iostream>
class Room {
private:
std::string name;
public:
Room(std::string name) : name(name) {
std::cout << "Room::constructor" << std::endl;
}
virtual ~Room() {
std::cout << "Room::destructor" << std::endl;
}
virtual void print() const {
std::cout << "Room " << name << std::endl;
}
};
#endif //EXAMPLE11_ROOM_H

View File

@@ -0,0 +1,15 @@
#include <iostream>
#include "House.h"
int main() {
std::cout << "Composition example" << std::endl;
{
std::cout << "----------- nested block begin -----------" << std::endl;
House h1("My home");
h1.print();
std::cout << "----------- nested block end -----------" << std::endl;
}
std::cout<<"House and rooms don't exist anymore!" << std::endl;
return 0;
}