Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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