Неразрешённый внешний символ
Ошибка на 272-274 строке кода. Неразрешённый внешний символ private static int count; private static char name[100]; private static File arr[100];
#include <iostream>
#include <string>
#include <iterator>
using namespace std;
class Date {
protected:
static inline int day;
static inline int month;
static inline int year;
public:
Date(void) {
}
Date(int day, int month, int year)
{
this->day = day;
this->month = month;
this->year = year;
}
Date(const Date &obj) {
this->day = obj.day;
this->month = obj.month;
this->year = obj.year;
}
~Date(){
}
static int GetDate() {
return day;
}
static int GetMonth() {
return month;
}
static int GetYear() {
return year;
}
static void SetDate(int value) {
day = value;
}
static void SetMonth(int value) {
month = value;
}
static void SetYear(int value) {
year = value;
}
void operator += (const int& value) {
if ((value <= 31) && (value >= 0)) {
day += value;
}
else if ((value > 31)&&(value <= 372)) {
month += value / 31;
day += value % 31;
}
else if (value > 372) {
year += value / 372;
month += (value-((value / 372)* 372))/31;
day += (value - ((value / 372) * 372)) % 31;
}
}
void operator -= (const int& value) {
int temp = 0;
temp += day;
temp += month * 31;
temp += year * 372;
temp -= value;
year = temp / 372;
month = (temp - ((temp / 372) * 372)) / 31;
day = (temp - ((temp / 372) * 372)) % 31;
if (month == 0) {
year -= 1;
month = 12;
}
}
friend ostream& operator<<(ostream& os, const Date& d) {
return os << d.GetDate() << "." << d.GetMonth() << "." << d.GetYear();
}
friend istream& operator>>(istream& is, const Date& d) {
int temp;
while (true) {
is >> temp;
if ((temp > 31) || (temp < 0)) {
cout << "Введённое некорректное значение даты. Попробуйте ещё раз" << endl;
}
else {
d.day = temp;
break;
}
}
while (true) {
is >> temp;
if ((temp > 12) || (temp < 0)) {
cout << "Введённое некорректное значение месяца. Попробуйте ещё раз" << endl;
}
else {
d.month = temp;
break;
}
}
while (true) {
is >> temp;
if (temp < 0) {
cout << "Введённое некорректное значение года. Попробуйте ещё раз" << endl;
}
else {
d.year = temp;
break;
}
}
return is;
}
void operator =(Date& obj)
{
this->day = obj.day;
this->month = obj.month;
this->year = obj.year;
}
};
class Time {
protected:
static inline int second;
static inline int minute;
static inline int hour;
public:
Time(void) {
}
Time(int second, int minute, int hour)
{
this->second = second;
this->minute = minute;
this->hour = hour;
}
Time(const Time& obj) {
this->second = obj.second;
this->minute = obj.minute;
this->hour = obj.hour;
}
~Time() {
}
static int GetSecond() {
return second;
}
static int GetMinute() {
return minute;
}
static int GetHour() {
return hour;
}
static void SetSecond(int value) {
second = value;
}
static void SetMinute(int value) {
minute = value;
}
static void SetHour(int value) {
hour = value;
}
friend ostream& operator<<(ostream& os, const Time& t) {
return os << t.GetSecond() << ":" << t.GetMinute() << ":" << t.GetHour();
}
friend istream& operator>>(istream& is, const Time& t) {
int temp;
while (true) {
is >> temp;
if ((temp >= 60) || (temp < 0)) {
cout << "Введённое некорректное значение секунд(ы). Попробуйте ещё раз" << endl;
}
else {
t.second = temp;
break;
}
}
while (true) {
is >> temp;
if ((temp >= 60) || (temp < 0)) {
cout << "Введённое некорректное значение минут(ы). Попробуйте ещё раз" << endl;
}
else {
t.minute = temp;
break;
}
}
while (true) {
is >> temp;
if ((temp < 0) || (temp >= 24)) {
cout << "Введённое некорректное значение часа(ов). Попробуйте ещё раз" << endl;
}
else {
t.hour = temp;
break;
}
}
return is;
}
void operator =(Time& obj)
{
this->second = obj.second;
this->minute = obj.minute;
this->hour = obj.hour;
}
};
class File :public Date, public Time
{
protected:
char name[40];
int size;
char atrributes[20];
public:
File(int day, int month, int year, int hour, int minute, int second, char name[40], int size, char atrributes[20]) :Date(day, month, year), Time(hour, minute, second)
{
strcpy_s(this->name, name);
this->size = size;
strcpy_s(this->atrributes, atrributes);
}
File()
{
}
~File()
{
}
void SetName(char name[40])
{
strcpy_s(this->name, name);
}
void SetAtrributes(char atrributes[20])
{
strcpy_s(this->atrributes, atrributes);
}
void SetSize(int size)
{
this->size = size;
}
char* GetName()
{
return this->name;
}
char* GetAtrributes()
{
return atrributes;
}
int GetSize()
{
return this->size;
}
friend ostream& operator<<(ostream& os, const File& dt) {
os << dt.name << " " << dt.size << " " << dt.atrributes << " " << dt.day << " " << dt.month << " " << dt.year << " " << dt.hour << " " << dt.minute << " " << dt.second << endl;
return os;
};
friend istream& operator >> (istream& in, File& dt) {
cout << "Введите название файла" << endl;
cin >> dt.name;
cout << "Введите размер файла" << endl;
in >> dt.size;
cout << "Введите атрибуты файла" << endl;
in >> dt.atrributes;
cout << "Введите дату создания файла, в формате дата, месяц, год" << endl;
in >> dt.day >> dt.month >> dt.year;
cout << "Введите время создания файла, в формате секунда, минута, час" << endl;
in >> dt.second >> dt.minute >> dt.hour;
return in;
};
};
class Catalog
{
private:
static File arr[100];
static char name[100];
static int count;
public:
Catalog()
{
}
Catalog(char name[100])
{
count = 0;
strcpy_s(this->name, name);
}
~Catalog()
{
}
/*void AddFile(int day, int month, int year, int hour, int minute, int second, char name[40], int size, char atrributes[20])//метод дабавления - создаем файл и заносим его в массив
{
File a(day, month, year, hour, minute, second, name, size, atrributes);
arr[count] = a;
count++;
}*/
void DeleteFile(char name[40])
{
for (int i = 0; i < count; i++)
{
if (!strcmp(arr[i].GetName(), name))
{
for (int j = i; j < count; j++)
{
arr[j] = arr[j + 1];
}
count--;
}
}
}
void Show()
{
for (int i = 0; i < count; i++)
{
cout << arr[i];
}
}
void FindByMask(char mask[100])
{
for (int i = 0; i < count; i++){
{
if (strstr(arr[i].GetName(), mask) != NULL)
{
cout << arr[i];
}
}
}
}
void SetName(char name[100])
{
strcpy_s(this->name, name);
count = 0;
}
void AddFile(){
File a;
cin >> a;
arr[count] = a;
count++;
};
};
class MyIterator : public std::iterator<std::input_iterator_tag, int>
{
File* p;
public:
MyIterator(File* x) :p(x) {
}
MyIterator(const MyIterator& mit) : p(mit.p) {
}
MyIterator& operator++() {
++p;
return *this;
}
MyIterator operator++(int) {
MyIterator tmp(*this);
operator++();
return tmp;
}
bool operator==(const MyIterator& rhs) const {
return p == rhs.p;
}
bool operator!=(const MyIterator& rhs) const {
return p != rhs.p;
}
File& operator*() {
return *p;
}
};
int main()
{
setlocale(LC_ALL, "Russian");
Catalog a;
while (true)
{
cout << "1) Создать новый каталог" << endl;//выводим меню
cout << "2) Добавить файл" << endl;
cout << "3) Удалить файл" << endl;
cout << "4) Показать каталог" << endl;
cout << "5) Найти файл по маске" << endl;
cout << "6) Выход" << endl;
int ch;
cin >> ch;
if (ch == 1)
{
char name[100];
cout << "Название каталога:\n";
cin >> name;
a.SetName(name);
}
if (ch == 2)
{
/*
int day;
int month;
int year;
int hour;
int minute;
int second;
char name[40];
int size;
char atrributes[20];
cout << "Enter name ";
cin >> name;
cout << "Enter size ";
cin >> size;
cout << "Enter attributes";
cin >> atrributes;
cout << "Enter hour ";
cin >> hour;
cout << "Enter minute ";
cin >> minute;
cout << "Enter second";
cin >> second;
cout << "Enter day ";
cin >> day;
cout << "Enter month ";
cin >> month;
cout << "Enter year";
cin >> year;
a.AddFile(day, month, year, hour, minute, second, name, size, atrributes);
cout << "File added!";
*/
a.AddFile();
}
if (ch == 3)////если выбрали пункт 3 - вводим именя файла и вызываем удаление файла
{
char name[100];
cout << "Input file name:";
cin >> name;
a.DeleteFile(name);
}
if (ch == 4)////если выбрали пункт 4 - вызываем вывод каталога
{
a.Show();
}
if (ch == 5)////если выбрали пункт 5 - вводим маску и вызываем поиск по маске
{
char mask[100];
cout << "Input mask:";
cin >> mask;
a.FindByMask(mask);
}
if (ch == 6)////если выбрали пункт 6 - выходим из цикла и закрываем программу
{
break;
}
}
}