Created
April 26, 2018 07:15
-
-
Save emirozturk/58df0a04cf7dea87ff3ca55fe94e4803 to your computer and use it in GitHub Desktop.
Virtual Functions
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> | |
using namespace std; | |
class temel { | |
public: | |
virtual void calis() { //virtual silersek ne olur | |
cout << "temel calisti" << endl; | |
} | |
}; | |
class A : public temel { | |
public: | |
void calis() { | |
cout << "A calisti" << endl; | |
} | |
}; | |
void fonk(temel *x) //Pointer'ı silersek ne olur | |
{ | |
x->calis(); | |
} | |
void fonk2(temel x) | |
{ | |
x.calis(); | |
} | |
int main() | |
{ | |
temel t; | |
A a; | |
fonk(&t); | |
fonk(&a); | |
fonk(t); | |
fonk(a); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment