Skip to content

Commit 0c799f3

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 2e5976f commit 0c799f3

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
@@ -3870,6 +3870,21 @@
38703870
\end{codeblock}
38713871
\end{example}
38723872

3873+
\pnum
3874+
A virtual function shall not be an explicit object member
3875+
function\iref{dcl.fct}.
3876+
\begin{example}
3877+
\begin{codeblock}
3878+
struct B {
3879+
virtual void g(); // \#1
3880+
};
3881+
struct D : B {
3882+
virtual void f(this D&); // error: explicit object member function cannot be virtual
3883+
void g(this D&); // overrides \#1; error: explicit object member function cannot be virtual
3884+
};
3885+
\end{codeblock}
3886+
\end{example}
3887+
38733888
\pnum
38743889
The \grammarterm{ref-qualifier}, or lack thereof, of an overriding function
38753890
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
@@ -3579,7 +3579,7 @@
35793579
A \grammarterm{member-declarator} with an explicit-object-parameter-declaration
35803580
shall not include
35813581
a \grammarterm{ref-qualifier} or a \grammarterm{cv-qualifier-seq} and
3582-
shall not be declared \keyword{static} or \keyword{virtual}.
3582+
shall not be declared \keyword{static}.
35833583
\begin{example}
35843584
\begin{codeblock}
35853585
struct C {

0 commit comments

Comments
 (0)