public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paul Koning <paulkoning@comcast.net>
To: Andrew Pinski <pinskia@gmail.com>
Cc: GCC Development <gcc@gcc.gnu.org>
Subject: Re: Possible C++ method signature warning feature?
Date: Thu, 11 Aug 2022 09:00:27 -0400	[thread overview]
Message-ID: <B2E3F27E-E12A-45C9-AA59-521830A4D2A3@comcast.net> (raw)
In-Reply-To: <CA+=Sn1n0phHFP_NFYECT-n4Qs5fUhOvaJm8FSK-r19C=Kj_SNw@mail.gmail.com>



> On Aug 10, 2022, at 9:25 PM, Andrew Pinski <pinskia@gmail.com> wrote:
> 
> On Wed, Aug 10, 2022 at 6:20 PM Paul Koning via Gcc <gcc@gcc.gnu.org> wrote:
>> 
>> There's a C++ problem I keep running into, in a very large body of software with lots of subclassing.
>> 
>> There's a base class that defines a set of interface methods, not all pure virtual (some define the default behavior).  A number of subclasses override some but not all of these.
>> 
>> Now I find myself changing the argument list of some of these methods, so I have to change the base class definitions and also track down all the subclass redefinitions.  If I miss one of the latter, that subclass method is no longer called (it now just looks like an unrelated method with a different argument list that isn't used anywhere).  Finding these things can be hard and time consuming.
>> 
>> It would be helpful to have some way to mark a method as "this is supposed to be an override of a base class method", in other words "warn me if this method doesn't override some method in a base class".
> 
> C++11's overload keyword sounds exactly what you want.
> https://en.cppreference.com/w/cpp/language/override

Perfect!  Thanks much.

	paul


      reply	other threads:[~2022-08-11 13:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-11  1:18 Paul Koning
2022-08-11  1:25 ` Andrew Pinski
2022-08-11 13:00   ` Paul Koning [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B2E3F27E-E12A-45C9-AA59-521830A4D2A3@comcast.net \
    --to=paulkoning@comcast.net \
    --cc=gcc@gcc.gnu.org \
    --cc=pinskia@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).