byanigli
Hectopat
Daha fazla
- Cinsiyet
- Erkek
- Meslek
- student of software engineering
Kod:
#include <iostream>
#include <string>
using namespace std;
class countary{
string nameofthecountry;
int population;
float area;
public:
void setnameofthecountry(string c);
void setpopulation(int p);
void setarea(float a);
void getname();
int getpopulation();
float getarea();
};
void countary::setnameofthecountry(string c)
{
c=nameofthecountry;
}
void countary::setpopulation(int p)
{
p=population;
}
void countary::setarea(float a)
{
a=area;
}
void countary::getname()
{
cout << nameofthecountry;
}
int countary::getpopulation()
{
return population;
}
float countary::getarea()
{
return area;
}
int main()
{
int i,pop;
string name;
float b;
countary benimarray[5];
for (i = 0; i <5; i++)
{
cout << "enter" << i + 1 << ". countary" << endl;
cin >> name;
benimarray[i].setnameofthecountry(name);
cout << "enter " << i + 1 << ". population\n";
cin >> pop;
benimarray[i].setpopulation(pop);
cout << "enter" << i + 1 << " area\n";
cin >> b;
benimarray[i].setarea(b);
}
int maxpopulation = benimarray[0].getpopulation();
int x,y;
for (x = 0; x < 5; x++)
{
if (maxpopulation<benimarray[x].getpopulation())
{
maxpopulation = benimarray[x].getpopulation();
y = x;
}
}
cout << maxpopulation << "sahip populasyon ile en buyuk ulke";
benimarray[y].getname();
getchar();
getchar();
return 0;
}
Çözümü : Arkadaşlar methodlarda syntax hatası vardır. Örneğin a=area; değil area=a; olmalıdır.
Son düzenleme: