Where to use the override keyword in C++

You can’t put an override specifier when defining the function outside the class’s member specification. The language doesn’t allow it, and a compiler will complain. So there’s really only one option.

Beyond that, this option also makes more sense. When declaring the function you are expressing an intent to override it. So putting override there at the point of expressing your intent makes sense. That is what you are asking the compiler to check here, your intent to override. The declaration is also enough to verify that function is originally declared virtual and that you got the signature right.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)