Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
NYP 5. Hafta
#include <iostream>
#include <string>
using namespace std;
class kisi {
private:
string _ad;
int _yas;
public:
kisi(string ad, int yas) {
_ad = ad;
_yas = yas;
}
string adAl() {
return _ad;
}
int yasAl() {
return _yas;
}
void yasDegistir(int yas) {
_yas = yas;
}
void adDegistir(string ad) {
_ad = ad;
}
bool operator==(kisi &k)
{
if (_yas == k.yasAl())
return true;
else return false;
}
bool operator<(kisi &k)
{
if (_yas < k.yasAl())
return true;
else return false;
}
};
int main()
{
kisi k1("Emir", 11);
kisi k2("Ahmet", 22);
if (k1 == k2)
cout << "Aynı yastalar" << endl;
else if (k1 < k2)
cout << k1.adAl() << " daha kucuk" << endl;
else
cout << k1.adAl() << " daha buyuk" << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment