Skip to content

Commit 59c8164

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 508c4f9 commit 59c8164

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

source/classes.tex

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3880,6 +3880,21 @@
38803880
\end{codeblock}
38813881
\end{example}
38823882

3883+
\pnum
3884+
A virtual function shall not be an explicit object member
3885+
function\iref{dcl.fct}.
3886+
\begin{example}
3887+
\begin{codeblock}
3888+
struct B {
3889+
virtual void g(); // \#1
3890+
};
3891+
struct D : B {
3892+
virtual void f(this D&); // error: explicit object member function cannot be virtual
3893+
void g(this D&); // overrides \#1; error: explicit object member function cannot be virtual
3894+
};
3895+
\end{codeblock}
3896+
\end{example}
3897+
38833898
\pnum
38843899
The \grammarterm{ref-qualifier}, or lack thereof, of an overriding function
38853900
shall be the same as that of the overridden function.

source/declarations.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3894,7 +3894,7 @@
38943894
A \grammarterm{member-declarator} with an explicit-object-parameter-declaration
38953895
shall not include
38963896
a \grammarterm{ref-qualifier} or a \grammarterm{cv-qualifier-seq} and
3897-
shall not be declared \keyword{static} or \keyword{virtual}.
3897+
shall not be declared \keyword{static}.
38983898
\begin{example}
38993899
\begin{codeblock}
39003900
struct C {

0 commit comments

Comments
 (0)