Как исправить ошибку «cout не является однозначным»?

А так же выдает ошибку 'эта переменная не содержит класс хранения или спецификатор типа'
В чем проблема?(
Подскажите пожаалулйстааа))))

#include
#include
using namespace std;

class country
{

public:

country();
country(char* aname , double at_winter, double at_spring,double at_summer,double at_autumn);
country(const country& CONTRY);
~country();

char* Returnname() { return name; };
double ReturnT_Winter() { return t_winter; };
double ReturnT_Spring() { return t_spring; };
double ReturnT_Summer() { return t_summer; };
double ReturnT_Autumn() { return t_autumn; };

friend ostream& operator<<(ostream& OUT, const country& COUNTRY);
friend istream& operator>>(istream& IN, country& COUNTRY);

country& operator=(const country& COUNTRY);

protected:

char* name;
double t_winter, t_spring, t_summer, t_autumn;

};

class NewCountry : public country {
public:

NewCountry();
NewCountry(char* aname, double at_winter, double at_spring, double at_summer, double at_autumn, int apolusharie);
NewCountry(const NewCountry& COUNTRY);
~NewCountry();

unsigned short int gpolusharie() { return polusharie; };
string sReturnpolusharie();

friend ostream& operator<<(ostream& OUT, const NewCountry& COUNTRY);
friend istream& operator>>(istream& IN, NewCountry& COUNTRY);

NewCountry& operator=(const NewCountry& COUNTRY);

private:
unsigned short int polusharie;
};

country::country()
{
name = NULL;
t_winter = NULL;
t_spring = NULL;
t_summer = NULL;
t_autumn = NULL;
};

country::country(char* aname, double at_winter, double at_spring, double at_summer, double at_autumn) :
name(new char[strlen(aname) + 1])
{
strcpy_s(name, strlen(aname) + 1, aname);
t_winter = at_winter;
t_spring = at_spring;
t_summer = at_summer;
t_autumn = at_autumn;
};

country::country(const country& COUNTRY) :
name(new char[strlen(COUNTRY.name) + 1])
{
strcpy_s(name, strlen(COUNTRY.name) + 1, COUNTRY.name);
t_winter = COUNTRY.t_winter;
t_spring = COUNTRY.t_spring;
t_summer = COUNTRY.t_summer;
t_autumn = COUNTRY.t_autumn;
};

country::~country()
{
delete[] name;
};

ostream& operator<<(ostream& Out, const country& COUNTRY)
{
Out << "\nСТРАНА: " << COUNTRY.name << "\nТЕМПЕРАТУРА ЗИМОЙ" << COUNTRY.t_winter << "\nТЕМПЕРАТУРА ВЕСНОЙ" << COUNTRY.t_spring << "\nТЕМПЕРАТУРА ЛЕТОМ" << COUNTRY.t_summer << "\nТЕМПЕРАТУРА ОСЕНЬЮ " << COUNTRY.t_autumn;

return Out;
};

istream& operator>>(istream& In, country& COUNTRY)
{
char TEMP[123];
In >> TEMP >> COUNTRY.t_winter >> COUNTRY.t_spring >> COUNTRY.t_summer >> COUNTRY.t_autumn;
delete[] COUNTRY.name;
COUNTRY.name = new char[strlen(TEMP) + 1];
strcpy_s(COUNTRY.name, strlen(TEMP) + 1, TEMP);
return In;
};

country& country::operator=(const country& COUNTRY) {
if (this == &COUNTRY) return *this;
delete[] name;
name = new char[strlen(COUNTRY.name) + 1];
strcpy_s(name, strlen(COUNTRY.name) + 1, COUNTRY.name);
name = COUNTRY.name;
t_winter = COUNTRY.t_winter;
t_spring = COUNTRY.t_spring;
t_summer = COUNTRY.t_summer;
t_autumn = COUNTRY.t_autumn;
return *this;
};

NewCountry::NewCountry() :
country()
{
polusharie = NULL;
};

NewCountry::NewCountry(char* aname, double at_winter, double at_spring, double at_summer, double at_autumn, int apolusharie) :
country(aname,at_winter, at_spring, at_summer, at_autumn)
{
polusharie = apolusharie;
};

NewCountry::NewCountry(const NewCountry& COUNTRY) :
country(COUNTRY)
{
polusharie = COUNTRY.polusharie;
};

NewCountry::~NewCountry()
{
delete[]name;
};

string NewCountry::sReturnpolusharie() {
if (polusharie == 1) return "северное";
if (polusharie == 2) return "южное";
if (polusharie == 3) return "по обе стороны экватора";
return "!!!ОШИБКА:данные отсутствуют!!!";
};

ostream& operator<<(ostream& Out, const NewCountry& COUNTRY)
{
Out << "\nСТРАНА: " << COUNTRY.name << "\nТЕМПЕРАТУРА ЗИМОЙ" << COUNTRY.t_winter << "\nТЕМПЕРАТУРА ВЕСНОЙ" << COUNTRY.t_spring << "\nТЕМПЕРАТУРА ЛЕТОМ" << COUNTRY.t_summer << "\nТЕМПЕРАТУРА ОСЕНЬЮ " << COUNTRY.t_autumn;
Out << "\nРАСПОЛОЖЕНИЕ ОТНОСИТЕЛЬНО ЭКВАТОРА: ";
if (COUNTRY.polusharie == 1) Out << "СЕВЕРНОЕ";
if (COUNTRY.polusharie == 2) Out << "ЮЖНОЕ";
if (COUNTRY.polusharie == 3) Out << "ПО ОБЕ СТОРОНЫ ЭКВАТОРА";
return Out;
};

istream& operator>>(istream& In, NewCountry& COUNTRY)
{
char TEMP[123];
In >> TEMP >> COUNTRY.t_winter >> COUNTRY.t_spring >> COUNTRY.t_summer >> COUNTRY.t_autumn >> COUNTRY.polusharie;
delete[] COUNTRY.name;
COUNTRY.name = new char[strlen(TEMP) + 1];
strcpy_s(COUNTRY.name, strlen(TEMP) + 1, TEMP);
return In;
};

NewCountry& NewCountry::operator=(const NewCountry& COUNTRY) {
if (this == &COUNTRY) return *this;
delete[] name;
name = new char[strlen(COUNTRY.name) + 1];
strcpy_s(name, strlen(COUNTRY.name) + 1, COUNTRY.name);
t_winter = COUNTRY.t_winter;
t_spring = COUNTRY.t_spring;
t_summer = COUNTRY.t_summer;
t_autumn = COUNTRY.t_autumn;
polusharie = COUNTRY.polusharie;
return *this;
};

void main() {
setlocale(LC_ALL, "Russian");
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
int N;
double winter = lol[0].ReturnT_Winter;
double summer = lol[0].ReturnT_Summer;
NewCountry* lol;
cout << "КОЛИЧЕСТВО СТРАН: ";
cin >> N;
lol = new NewCountry[N];
cout << "Введите данные\nНазвание страны , температура зимой,весной и летом, в каком полушарии находится (1 - северное, 2 - южное, 3 - по обе стороны экватора ):\n\n";
for ( int i = 0; i < N; i++) cin >> lol[i];
for ( int i = 0; i < N; i++)
{
if (winter < lol[i].ReturnT_Winter())
winter = lol[i].ReturnT_Winter();
if (summer > lol[i].ReturnT_Summer ())
summer = lol[i].ReturnT_Summer();
}
};
cout << "\nПроверка оператора =\n";
lol[0] = lol[1];
cout << lol[0] << endl;
cout << lol[1] << endl;
cout << "\nПроверка конструктора копирования\n";
NewCountry Copy(lol[2]);
cout << Copy << endl;
cout << lol[2] << endl;
delete[] lol;
system("pause");
};
  • Вопрос задан
  • 4325 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы