Possible Duplicate:
C++ Overriding… overwriting?
What's the difference between override
and overwrite
? I've heard them used interchangeably but I suspect that's incorrect.
Possible Duplicate:
C++ Overriding… overwriting?
What's the difference between override
and overwrite
? I've heard them used interchangeably but I suspect that's incorrect.
You can only overwrite what's been written and where it's been written, while you can override things elsewhere (for instance you can override members of base class in derived classes).
override
is a C++11 keyword used to override base virtual method:
class A
{
virtual f(int) {}
};
class B
{
virtual f(int) override {} // override A::f(int)
};
This lets you make sure that A::F(int)
gets overriden, meaning you are not creating new virtual function.
Of course this code won't compile if the function signature was different.
overwrite is not C++ keyword and it basically means to overwrite some file or text with new one.
The keyword override
has been introduced because some times a programmer doesn't know whether he is overriding or whether he is creating a new virtual method with a different signature.
Using that keyword you either get an error or override virtual method.