интересует функция void show ()
в классе WeekBalance
, которая должна выводить массив вектор данных класса Voucher
.
#include <iomanip>
#include <cstdlib>
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
using namespace std;
class Date {
int year;
int month;
int day;
public:
Date (int year, int month, int day) {
this->year = year;
this->month = month;
this->day = day;
}
};
class Bus {
int seatsNumber;
int petrolPer100km;
public:
Bus (int seatsNumber, int petrolPer100km) {
this->seatsNumber = seatsNumber;
this->petrolPer100km = petrolPer100km;
}
};
class Person {
string name;
string surname;
Date* birthday;
public:
Person ( string name, string surname, Date* birthday) {
this->name = name;
this->surname = surname;
this->birthday = birthday;
}
};
class Application {
string finalPoint;
int length;
public:
Application (string finalPoint, int length) {
this->finalPoint = finalPoint;
this->length = length;
}
friend class WeekBalance;
};
class Driver : public Person {
string category;
float salary;
string dateofadmission;
public:
Driver (string name, string surname, Date* birthday, string category, float salary, string dateofadmission) : Person ( name, surname, birthday)
{
this->category = category;
this->salary = salary;
this->dateofadmission = dateofadmission;
}
};
class Voucher : public Bus, public Application, public Driver {
public:
int dateofcompletion;
int petrol;
public:
Voucher(int seatsNumber, int petrolPer100km, string finalPoint, int length, string name, string surname, Date* birthday, string category, float salary, string dateofadmission, int dateofcompletion, int petrol ) : Bus (seatsNumber, petrolPer100km), Application (finalPoint, length), Driver(name, surname, birthday, category, salary, dateofadmission)
{
this->dateofcompletion = dateofcompletion;
this->petrol = petrol;
}
};
class WeekBalance {
private:
std::vector<Voucher> m_voucher;
public:
void show() {
for (int i = 0; i < m_voucher.size(); i++) {
cout << (i+1) << ") " << m_voucher[i].dateofcompletion << m_voucher[i].petrol << m_voucher[i].finalPoint << endl; // ЦИКЛ НЕ РАБОТАЕТ не выводит данные finalPoint dateofcompletion Petrol
}
}
};
int main() {
Date d2 (21,5,2020);
Voucher (1,2,"lviv", 2, "sda", "sdsd", &d2, "c", 455, "sd", 3, 4);
Voucher (4,5,"hk", 2, "dd", "sd", &d2, "sd", 3, "sd", 9, 1);
WeekBalance b; // НЕ ВЫВОДИТ
b.show();
return 0;
}
ПРАВИЛЬНО ЛИ Я ЗАПОЛНЯЮ МАССИВЫ
void show() {
for (int i = 0; i < m_voucher.size(); i++) { m_voucher[i].petrol = petrol;}
for (int i = 0; i < m_voucher.size(); i++) {
cout << (i+1) << ") " << m_voucher[i].dateofcompletion << m_voucher[i].petrol << m_voucher[i].finalPoint << endl;
}
}