C++
Marked Override Does Not Override Fix
The override specifier is a promise: this function replaces a virtual function from the base class. When GCC answers 'marked override, but does not override', the promise failed — the derived function matches nothing in the base, so calls through the base would never reach it. This guide reads the diagnostic, separates the five mismatches that cause it, and fixes each one by making the derived signature the one the base actually declares.
Written November 28, 2026 · Tested with GCC 13.3.0 · 8 min read
- The failure: a const on one side only
- Cause 2: the parameter list differs
- Cause 3: the name differs
- Cause 4: the base function is not virtual at all
Written November 28, 2026
Tested with GCC 13.3.0
What this guide is
A derived-class function overrides a base-class virtual function only when the two agree on the parts of the signature that define the match: the name, the parameter type list, the cv-qualifiers (the const after the parameter list), and the ref-qualifiers (a trailing & or &&). The override specifier turns that match into a checked promise: it specifies that the function overrides a virtual function from a base class, and the program is ill-formed — a compile-time error — if that is not true. Without override, a near-miss signature is legal C++ that silently does something else: it declares a new function that hides the base one, and calls through a base reference or pointer keep going to the base version. The error in this guide is the sound of the check working.
That framing decides the fix before any code changes. The derived function was written to be called through the base interface; the base does not have a virtual function with that exact signature; so one of the two declarations is not the one its author meant. Every cause below is a different way for the two declarations to disagree, and the diagnostic alone does not say which side is wrong — it quotes the derived signature and stops. The work is comparing the two declarations part by part, deciding which one states the intended interface, and changing that one. Deleting override is never the fix: it converts the error into the silent hiding the specifier exists to catch, and the last section of this guide shows exactly what that costs.
Build every program in this guide with g++ -std=c++20 -g.
The failure: a const on one side only
The most common form of this error is a const that appears in the derived class but not in the base, or the other way round. Here the base function is non-const and the derived one is const:
#include <iostream>
struct Base {
virtual void name() { std::cout << "Base::name\n"; }
virtual ~Base() = default;
};
struct Derived : Base {
void name() const override { std::cout << "Derived::name\n"; }
};
int main() {
Derived d;
d.name();
return 0;
}
$ g++ -std=c++20 -g -o const-mismatch const-mismatch.cpp
const-mismatch.cpp:9:10: error: 'void Derived::name() const' marked 'override', but does not override
9 | void name() const override { std::cout << "Derived::name\n"; }
| ^~~~
Read the error in its parts. The fixed wording is marked 'override', but does not override, and the quoted signature before it — 'void Derived::name() const' — is the derived function exactly as declared, const included. The caret span sits under the function name in the derived class, and that is the whole report: GCC prints no note: line pointing at the base declaration it failed to match, because there is no single base function to point at — the derived signature matches none of them. The comparison is therefore yours to make, and the first place to look is the end of the derived signature, where the qualifiers live. A const member function and a non-const member function are different functions with different signatures; the derived one here does not override the base one, it overloads nothing and hides the base name within the derived class — and override is what turns that quiet outcome into an error.
Which side to change is a design question, not a compiler question. If the operation genuinely does not modify the object, the base declaration is the one missing its const, and adding it there makes the derived function an override — but that also changes the base interface for every other derived class and every caller holding a const base reference. If the operation does modify the object, the derived const is the mistake and comes off. The compiler cannot know which; it can only refuse to let the disagreement pass unnoticed.
Cause 2: the parameter list differs
The second cause is a parameter type that is close but not identical. An int parameter and a long parameter accept many of the same values, and a call with a literal compiles against either — but they are different types, so the parameter lists differ:
#include <iostream>
struct Base {
virtual void name(int value) { std::cout << "Base::name(int)\n"; }
virtual ~Base() = default;
};
struct Derived : Base {
void name(long value) override { std::cout << "Derived::name(long)\n"; }
};
int main() {
Derived d;
d.name(1);
return 0;
}
$ g++ -std=c++20 -g -o param-mismatch param-mismatch.cpp
param-mismatch.cpp:9:10: error: 'void Derived::name(long int)' marked 'override', but does not override
9 | void name(long value) override { std::cout << "Derived::name(long)\n"; }
| ^~~~
The quoted signature again names the derived function, 'void Derived::name(long int)' — GCC spells the parameter type out in full, long int, which is the fastest tell in this class: read the parameter list in the quoted signature and compare it, type by type, with the base declaration. Conversions do not count toward overriding. A derived function whose parameters merely convert to the base's parameters does not override it; without override it would hide the base function for calls made through the derived class while base-interface calls kept dispatching to the base version. The fix is to make the parameter types identical to the base's — change the derived parameter, or, if the wider type is the intended interface, change the base and every other overrider with it.
Cause 3: the name differs
The third cause is the plainest: the derived function has a different name, usually a typo made when the function was written or renamed in one class but not the other:
#include <iostream>
struct Base {
virtual void describe() { std::cout << "Base::describe\n"; }
virtual ~Base() = default;
};
struct Derived : Base {
void descirbe() override { std::cout << "Derived::descirbe\n"; }
};
int main() {
Derived d;
d.describe();
return 0;
}
$ g++ -std=c++20 -g -o name-typo name-typo.cpp
name-typo.cpp:9:10: error: 'void Derived::descirbe()' marked 'override', but does not override
9 | void descirbe() override { std::cout << "Derived::descirbe\n"; }
| ^~~~~~~~
The error is identical in form, and the quoted signature carries the evidence: 'void Derived::descirbe()' is not the base's describe. This is the cause override catches most cheaply — without the specifier, a misspelled overrider is just a new member function that nothing calls, and the base version keeps answering every call while the derived code sits dead. When the quoted name in the diagnostic is not the name you expected to read, the fix is the spelling, in whichever class has it wrong.
Cause 4: the base function is not virtual at all
The fourth cause sits in the base class: the function being "overridden" was never declared virtual, so there is no virtual function to override:
#include <iostream>
struct Base {
void name() { std::cout << "Base::name\n"; }
};
struct Derived : Base {
void name() override { std::cout << "Derived::name\n"; }
};
int main() {
Derived d;
d.name();
return 0;
}
$ g++ -std=c++20 -g -o not-virtual not-virtual.cpp
not-virtual.cpp:8:10: error: 'void Derived::name()' marked 'override', but does not override
8 | void name() override { std::cout << "Derived::name\n"; }
| ^~~~
Note what GCC does not do here: it does not print a different error saying the base function is not virtual. The wording is the same marked 'override', but does not override as for a signature mismatch, and the quoted signature, 'void Derived::name()', matches the base declaration character for character — name, parameters, qualifiers all agree. When the two declarations look identical and the error still fires, the missing piece is in the base: no virtual on the base function (or the function lives in a class this one does not actually derive from). The fix is to declare the base function virtual — which is a change to the base class's contract, making calls through it dispatch dynamically — or to accept that the function is not part of a polymorphic interface and remove both the derived copy's override and any expectation that base-interface calls reach it.
Cause 5: a ref-qualifier on one side only
The fifth cause is the least visible, because the differing part is a single character at the very end of the declaration. A ref-qualifier — the & that restricts a member function to lvalue objects — is part of the signature for overriding, like const:
#include <iostream>
struct Base {
virtual void name() { std::cout << "Base::name\n"; }
virtual ~Base() = default;
};
struct Derived : Base {
void name() & override { std::cout << "Derived::name\n"; }
};
int main() {
Derived d;
d.name();
return 0;
}
$ g++ -std=c++20 -g -o ref-qualifier ref-qualifier.cpp
ref-qualifier.cpp:9:10: error: 'void Derived::name() &' marked 'override', but does not override
9 | void name() & override { std::cout << "Derived::name\n"; }
| ^~~~
The quoted signature shows it: 'void Derived::name() &'. The base function has no ref-qualifier, so the derived function, which can only be called on an lvalue, is a different function from the base's, which can be called on any value. The same applies in reverse, and to &&. When the name, the parameters, and the const all match and the error persists, read the last character of both declarations before reading anything else.
The exception specification is not one of the causes
One part of the signature does not participate in the match the way the others do: the exception specification. Adding noexcept in the derived class, where the base function has none, is allowed — the derived function promises more than the base requires, and it overrides:
#include <iostream>
struct Base {
virtual void name() { std::cout << "Base::name\n"; }
virtual ~Base() = default;
};
struct Derived : Base {
void name() noexcept override { std::cout << "Derived::name\n"; }
};
int main() {
Derived d;
d.name();
return 0;
}
$ g++ -std=c++20 -g -o noexcept-mismatch noexcept-mismatch.cpp
No error, and the program runs. The reverse direction is an error, but a different one with different wording. If the base function is noexcept and the derived one drops it, the derived function offers a weaker guarantee than the interface promises, and GCC says so in its own terms:
#include <iostream>
struct Base {
virtual void name() noexcept { std::cout << "Base::name\n"; }
virtual ~Base() = default;
};
struct Derived : Base {
void name() override { std::cout << "Derived::name\n"; }
};
int main() {
Derived d;
d.name();
return 0;
}
$ g++ -std=c++20 -g -o noexcept-reverse noexcept-reverse.cpp
noexcept-reverse.cpp:9:10: error: looser exception specification on overriding virtual function 'virtual void Derived::name()'
9 | void name() override { std::cout << "Derived::name\n"; }
| ^~~~
noexcept-reverse.cpp:4:18: note: overridden function is 'virtual void Base::name() noexcept'
4 | virtual void name() noexcept { std::cout << "Base::name\n"; }
| ^~~~
looser exception specification on overriding virtual function, with a note: line that does point at the overridden function — the note the title error never prints. So an exception-specification problem never presents as marked 'override', but does not override: tightening is accepted silently, and loosening draws its own diagnostic. If the error you are reading is the title error, the exception specification is not where the mismatch is.
Key resultfive mismatches produce the identical sentence — a const on one side only, a different parameter type, a different name, a base function that is not virtual, and a ref-qualifier on one side only — and GCC quotes only the derived signature, with no note naming the base function it failed to match. The exception specification is the exception: addingnoexceptin the derived class is accepted, and removing it draws a different error entirely.
The fix: match the base signature exactly
Every fix above is the same shape: make the derived declaration agree with the base declaration on name, parameter types, cv-qualifiers, and ref-qualifiers — changing whichever side misstates the intended interface. Here is the const-mismatch program with the base declaration corrected to the const the operation actually honors, so the derived function overrides:
#include <iostream>
struct Base {
virtual void name() const { std::cout << "Base::name\n"; }
virtual ~Base() = default;
};
struct Derived : Base {
void name() const override { std::cout << "Derived::name\n"; }
};
int main() {
Derived d;
Base& ref = d;
ref.name();
Base* ptr = &d;
ptr->name();
return 0;
}
$ g++ -std=c++20 -g -o fixed fixed.cpp
$ ./fixed
Derived::name
Derived::name
It compiles, and the output is the proof that matters: both calls go through the base interface — one through a Base&, one through a Base* — and both print Derived::name. That is what overriding means in observable terms: the dynamic type of the object, not the static type of the reference or pointer, selects the function. A fix is not verified by the error disappearing; it is verified by a call through the base reaching the derived function, because a change that merely silences the diagnostic — the subject of the last section — leaves dispatch going to the base.
Similar errors that are not this one
Drop the override specifier and give the base a pure virtual function, and a signature mismatch stops being a complaint about the derived function and becomes a complaint about the derived class: it never implemented the interface, so it stays abstract:
#include <iostream>
struct Base {
virtual void name(int value) = 0;
virtual ~Base() = default;
};
struct Derived : Base {
void name(long value) { std::cout << "Derived::name(long)\n"; }
};
int main() {
Derived d;
d.name(1L);
return 0;
}
$ g++ -std=c++20 -g -o abstract abstract.cpp
abstract.cpp: In function 'int main()':
abstract.cpp:13:13: error: cannot declare variable 'd' to be of abstract type 'Derived'
13 | Derived d;
| ^
abstract.cpp:8:8: note: because the following virtual functions are pure within 'Derived':
8 | struct Derived : Base {
| ^~~~~~~
abstract.cpp:4:18: note: 'virtual void Base::name(int)'
4 | virtual void name(int value) = 0;
| ^~~~
The error is cannot declare variable 'd' to be of abstract type 'Derived', reported at the point where the object is created, not at the mismatched declaration — and here GCC does print notes, naming the pure virtual function that was never overridden. The mismatched name(long) in the derived class is not mentioned at all. Same underlying mistake as Cause 2, completely different diagnostic, reported in a different place: this is the error a missing override draws when nothing in the derived class claims to provide it.
The second look-alike is not an error at all. When a derived function has the same name as a base virtual function but a different parameter list, and no override is written, GCC's -Woverloaded-virtual warning reports that the base function was hidden:
#include <iostream>
struct Base {
virtual void name(int value) { std::cout << "Base::name(int)\n"; }
virtual ~Base() = default;
};
struct Derived : Base {
void name(double value) { std::cout << "Derived::name(double)\n"; }
};
int main() {
Derived d;
d.name(1.5);
return 0;
}
$ g++ -std=c++20 -g -Woverloaded-virtual -o hiding hiding.cpp
hiding.cpp:4:18: warning: 'virtual void Base::name(int)' was hidden [-Woverloaded-virtual=]
4 | virtual void name(int value) { std::cout << "Base::name(int)\n"; }
| ^~~~
hiding.cpp:9:10: note: by 'void Derived::name(double)'
9 | void name(double value) { std::cout << "Derived::name(double)\n"; }
| ^~~~
A warning, not an error: the build succeeds, the program runs, and Derived::name(double) answers the call made on the derived object — while any call through the base interface still goes to Base::name(int), which the derived declaration hid rather than replaced. The warning is the only signal, it appears only when the flag is enabled, and it is easy to miss in a long build log. That gap between a warning that can be missed and an error that cannot is the whole argument for writing override on every intended overrider.
Why deleting override is not a fix
The fastest way to make the title error disappear is to delete the word override. The compiler accepts the program immediately — and the bug the specifier caught goes silent. Here is the same mismatch from the other side — a const base function and a non-const derived function written without override:
#include <iostream>
struct Base {
virtual void name() const { std::cout << "Base::name\n"; }
virtual ~Base() = default;
};
struct Derived : Base {
void name() { std::cout << "Derived::name\n"; }
};
int main() {
Derived d;
Base& ref = d;
ref.name();
return 0;
}
$ g++ -std=c++20 -g -o no-override no-override.cpp
$ ./no-override
Base::name
It compiles with no diagnostic, and the call through Base& prints Base::name. The derived function exists, it is correct, it is simply never called through the base interface, because a non-const name() does not override a const name() — it hides it. Every property of the original error is still true of this program; only the report is gone. Whenever the title error fires, the derived function was written to be reached through the base, so the resolution is always to repair the match — on whichever side misstates the interface — never to remove the check that exposed the mismatch.
The fixes, ranked
Match the qualifiers when the quoted signature shows one the base lacks. Ranked first because it is the most common cause and the cheapest to confirm: compare the end of the quoted derived signature with the end of the base declaration — a const or a trailing & or && present on one side only is the whole defect. Then decide which side states the intended interface and change that side.
Make the parameter types identical when the quoted signature's parameter list differs. Conversions do not count: long does not override int, a value does not override a reference. Change the derived parameter to the base's type, or change the base interface and every overrider together if the new type is the intent.
Fix the spelling when the quoted name is not the base's name. A rename applied to one class, or a typo, leaves the derived function as dead code that nothing calls. Correct the name in the class that has it wrong.
Add virtual in the base when the two declarations are character-identical. If name, parameters, and qualifiers all agree and the error still fires, the base function is not virtual (or the class does not derive from the one declaring it). Making the base function virtual changes the base class's contract — calls through it now dispatch dynamically — so it is a deliberate interface change, not a tidy-up.
Never delete override to silence the error. It compiles, and dispatch silently stays with the base version. The specifier is the check; removing the check is the one outcome worse than the error.
Which fix for which cause
| What the diagnostic shows | Cause | Fix |
|---|---|---|
Quoted signature ends in const, base has none |
cv-qualifier mismatch | Match the const on both sides |
Quoted signature ends in & or && |
Ref-qualifier mismatch | Match the ref-qualifier on both sides |
| Quoted parameter type differs from base | Parameter list mismatch | Use the base's exact parameter types |
| Quoted name differs from base name | Typo or one-sided rename | Correct the name |
| Signatures identical, error still fires | Base function not virtual | Add virtual in the base |
looser exception specification error |
Derived dropped base's noexcept |
Restore noexcept in the derived |
cannot declare variable of abstract type |
Pure virtual never overridden | Provide an exact-match overrider |
was hidden warning, build succeeds |
Hiding, no override written |
Add override; fix the signature it flags |
Checklist
- Read the quoted signature in the error: it is the derived function exactly as declared, and every part of it — name, parameter types, trailing qualifiers — is a candidate mismatch.
- Expect no
note:line from this error: GCC does not name the base function that failed to match, so open the base declaration and compare the two side by side yourself. - Compare in this order: name, parameter types one by one,
const, ref-qualifier. Conversions between parameter types do not count toward a match. - If the two declarations look identical, check the base for
virtual— a non-virtual base function produces this same error, in the same words. - Do not chase the exception specification for this error: adding
noexceptin the derived class is accepted, and dropping the base'snoexceptdraws the separatelooser exception specificationerror. - Verify the fix by dispatch, not by silence: call through a base reference or pointer and confirm the derived function runs.
- Keep
overrideon every intended overrider. Without it, the same mismatch is at best a-Woverloaded-virtualwarning and at worst silent hiding, with base-interface calls going to the base version indefinitely. - When a class cannot be instantiated after a signature change, read for the abstract-type error instead: a pure virtual function with no exact-match overrider leaves the derived class abstract, and that error is reported at the object, not at the declaration.
Related guides on this site
- C++ Does Not Name a Type Fix
- 'std::unique' Is Not a Member of 'std' Fix
- 'std::search_n' Is Not a Member of 'std' Fix
- 'std::replace' Is Not a Member of 'std' Fix
Sources
- cppreference, override specifier — for the override specifier ensuring that a function is virtual and overrides a virtual function from a base class, and for the program being ill-formed when that is not true.
- cppreference, Virtual function specifier — for a derived function overriding a base virtual function only when the name, parameter type list, cv-qualifiers, and ref-qualifiers all match, for a same-name function with a different parameter list hiding rather than overriding the base function, and for a virtual call through a base reference or pointer invoking the derived class's behavior.
Keep Exploring
Seven tips and seven puzzles so far, each one a short runnable example with the fix explained.
Paste an AddressSanitizer, UBSan, or ThreadSanitizer report and get the bug, the file and line, and the fix \u2014 in plain language.
C++20 and C++23 features, migration paths, and measured trade-offs.
The full C++ hub \u2014 language basics, the standard library, coroutines, and measured comparisons.
Paste a [Service] section and get a plain-language verdict on every sandboxing setting it finds.