Created
April 12, 2018 08:45
-
-
Save emirozturk/b56e37fabfcce5f320ee9bcaf6522664 to your computer and use it in GitHub Desktop.
Static, Operator Overloading, Copy Constructor, References
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 sinif{ | |
string deger; | |
public: | |
static string sabitDeger; | |
sinif(string deger){ | |
this->deger = deger; | |
std::cout << "Yapici cagirildi " << deger << std::endl; | |
} | |
sinif(sinif &s){ | |
deger = s.degerAl(); | |
std::cout << "Kopya yapici cagirildi " << deger << std::endl; | |
} | |
sinif& operator=(sinif &sinif){ | |
this->deger = deger; | |
std::cout << "Atama operatoru cagirildi " << deger << std::endl; | |
return *this; | |
} | |
string degerAl(){ | |
return deger; | |
} | |
void degerAta(string deger){ | |
this->deger = deger; | |
} | |
void goster(){ | |
std::cout << deger << std::endl; | |
} | |
}; | |
string sinif::sabitDeger = "Statik"; | |
sinif fonksiyon(sinif nesne) | |
{ | |
return nesne; | |
} | |
sinif fonksiyon2(sinif &nesne) | |
{ | |
return nesne; | |
} | |
sinif &fonksiyon3(sinif &nesne) | |
{ | |
return nesne; | |
} | |
int main() { | |
cout << "sinif n1:"; | |
sinif n1("n1"); | |
cout << "n1.goster():"; | |
n1.goster(); | |
cout << "sinif n2:"; | |
sinif n2("n2"); | |
cout << "n2.goster():"; | |
n2.goster(); | |
cout << "n2=n1:"; | |
n2 = n1; | |
cout << "n2.goster():"; | |
n2.goster(); | |
cout << "sinif n3 = n1:"; | |
sinif n3 = n1; | |
cout << "n3.goster():"; | |
n3.goster(); | |
cout << "fonksiyon(n3):"; | |
fonksiyon(n3); | |
cout << "fonksiyon2(n3):"; | |
fonksiyon2(n3); | |
cout << "fonksiyon3(n3):"; | |
fonksiyon3(n3); | |
cout << "n3 = n2 = n1:"; | |
n3 = n2 = n1; | |
n1.sabitDeger = "SabitiDegistirdim"; | |
cout << n2.sabitDeger; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment