Created
April 5, 2018 08:12
-
-
Save emirozturk/47d7d5d2a319bc1f76bfd2ee8d9433f2 to your computer and use it in GitHub Desktop.
NYP 5. Hafta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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