1
0
Fork 0
mirror of https://github.com/dancojocaru2000/y3s2-cciot-hw.git synced 2025-02-22 17:09:35 +02:00
y3s2-cciot-hw/Lab1/README.md
2022-03-13 17:08:26 +02:00

76 lines
1.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# CCIoT Homework Lab 1
## Slide 11
### Problem
```cpp
class Human
{
public:
Human();
~Human();
std::string name;
int age;
};
```
Try this:
1. Create 4 humans.
2. Give them names and ages.
3. Retrieve the data from all humans and print it to the screen.
4. Print the data for the youngest human.
5. Print all humans names in descending order by their names.
### Solution
See [slide11.cpp](./slide11.cpp).
## Slide 13
### Problem
```cpp
class Human
{
public:
Human();
~Human();
private:
std::string name;
int age;
};
```
Try this:
1. Try to retrieve the data from all humans and print it to the screen.
2. Try to find a workaround for the errors (if you dont see any errors youre doing something wrong).
### Solution
1. Because the `name` and `age` fields are private, they cannot be accessed.
2. A solution would be creating getters for them:
```cpp
class Human
{
...
public:
const std::string& getName();
const int& getAge();
};
```
## Slide 17
### Problem
Write a program that implements a class hierarchy that can be used to model geometric shapes, based on the following structure:
[shape_start.cpp](./shape_start.cpp)
### Solution
See [shape_start_sol.cpp](./shape_start_sol.cpp).