A
A
AlkesPro2020-04-20 23:25:26
OOP
AlkesPro, 2020-04-20 23:25:26

How to insert class objects into a vector and display the properties of objects from the class on the screen?

I now have a task to bring a class object into a vector, and then display the properties of the object that are in the vector on the screen.

But so far I have no idea in which direction to dig. If anyone can help, please point me in the right direction.

For example, I will attach the class code:

class Tasks
{
private:
  std::string m_Name;
  std::string m_Desc;
  unsigned short m_Status;

public:
  Tasks(std::string Name, std::string Desc, unsigned short Status = 0) : m_Name{ Name = "None" }, m_Desc{ Desc = "None" }
  {
    m_Status = Status;
  }

  Tasks()
  {
    m_Name = "None";
    m_Desc = "None";
    m_Status = 4; // Тестовое значение
  }


  // Методы Tasks

  // Геттеры
  std::string get_m_Name() { return m_Name; }
  std::string get_m_Desc() { return m_Desc; }
  unsigned short get_m_Status() { return m_Status; }

  // Изменение данных класса
  void change_Name_Tasks();
  void change_Desc_Tasks();
  void change_Status_Tasks();

  void cout_Tasks();
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2020-04-20
@AlkesPro

You need to create a vector with object type - Tasks class. And already work with him as it should be.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question