C++'da programın çalışmasında hata!

byanigli

Hectopat
Katılım
3 Ocak 2014
Mesajlar
543
Yer
İzmir, Turkey, Turkey
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;

}
Kodlarımda her hangi bir sıkıntı görmüyorum, ama çalışmıyorda. Yardım ederseniz sevinirim .
Çözümü : Arkadaşlar methodlarda syntax hatası vardır. Örneğin a=area; değil area=a; olmalıdır.
 
Son düzenleme:
Bu siteyi kullanmak için çerezler gereklidir. Siteyi kullanmaya devam etmek için çerezleri kabul etmelisiniz. Daha Fazlasını Öğren.…