Homeworks for Cloud Computing and IoT lecture in year 3, semester 2
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Kenneth Bruen 0c2d77569a
Solved Lab1 Slide17
3 years ago
..
README.md Solved Lab1 Slide17 3 years ago
shape_start.cpp Solved Lab1 Slide17 3 years ago
shape_start_sol.cpp Solved Lab1 Slide17 3 years ago
slide11.cpp Initial commit, solve Lab1 Slide11 3 years ago

README.md

CCIoT Homework Lab 1

Slide 11

Problem

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.

Slide 13

Problem

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 don’t see any errors you’re 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:
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

Solution

See shape_start_sol.cpp.