Skip to content

Commit b96291c

Browse files
committed
[class.virtual] Explicit object member functions cannot be virtual
including when overriding a virtual function. Remove a prohibition focusing on 'declared virtual' from [dcl.fct].
1 parent f03473c commit b96291c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

source/classes.tex

+15
Original file line numberDiff line numberDiff line change
@@ -3728,6 +3728,21 @@
37283728
\end{codeblock}
37293729
\end{example}
37303730

3731+
\pnum
3732+
A virtual function shall not be an explicit object member
3733+
function\iref{dcl.fct}.
3734+
\begin{example}
3735+
\begin{codeblock}
3736+
struct B {
3737+
virtual void g(); // \#1
3738+
};
3739+
struct D : B {
3740+
virtual void f(this D&); // error: explicit object member function cannot be virtual
3741+
void g(this D&); // overrides \#1; error: explicit object member function cannot be virtual
3742+
};
3743+
\end{codeblock}
3744+
\end{example}
3745+
37313746
\pnum
37323747
The \grammarterm{ref-qualifier}, or lack thereof, of an overriding function
37333748
shall be the same as that of the overridden function.

source/declarations.tex

+1-1
Original file line numberDiff line numberDiff line change
@@ -3578,7 +3578,7 @@
35783578
A \grammarterm{member-declarator} with an explicit-object-parameter-declaration
35793579
shall not include
35803580
a \grammarterm{ref-qualifier} or a \grammarterm{cv-qualifier-seq} and
3581-
shall not be declared \keyword{static} or \keyword{virtual}.
3581+
shall not be declared \keyword{static}.
35823582
\begin{example}
35833583
\begin{codeblock}
35843584
struct C {

0 commit comments

Comments
 (0)