Skip to content

Instantly share code, notes, and snippets.

@emirozturk
Created Apr 12, 2018
Embed
What would you like to do?
Static, Operator Overloading, Copy Constructor, References
#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