Skip to content

Instantly share code, notes, and snippets.

@emirozturk
Created April 26, 2018 07:15
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/58df0a04cf7dea87ff3ca55fe94e4803 to your computer and use it in GitHub Desktop.
Save emirozturk/58df0a04cf7dea87ff3ca55fe94e4803 to your computer and use it in GitHub Desktop.
Virtual Functions
#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