Skip to content

Instantly share code, notes, and snippets.

@emirozturk
Created April 5, 2018 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emirozturk/47d7d5d2a319bc1f76bfd2ee8d9433f2 to your computer and use it in GitHub Desktop.
Save emirozturk/47d7d5d2a319bc1f76bfd2ee8d9433f2 to your computer and use it in GitHub Desktop.
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