Bjarne Stroustrup mentions in Design and Evolution of C++ that super as a keyword was considered by the ISO C++ Standards committee the first time C++ was standardized.

Dag Bruck proposed this extension, calling the base class "inherited." The proposal mentioned the multiple inheritance issue, and would have flagged ambiguous uses. Even Stroustrup was convinced.

After discussion, Dag Bruck (yes, the same person making the proposal) wrote that the proposal was implementable, technically sound, and free of major flaws, and handled multiple inheritance. On the other hand, there wasn't enough bang for the buck, and the committee should handle a thornier problem.

Michael Tiemann arrived late, and then showed that a typedef'ed super would work just fine, using the same technique that was asked about in this post.

So, no, this will probably never get standardized.

If you don't have a copy, Design and Evolution is well worth the cover price. Used copies can be had for about $10.

Answer from Max Lybbert on Stack Overflow
Top answer
1 of 16
182

Bjarne Stroustrup mentions in Design and Evolution of C++ that super as a keyword was considered by the ISO C++ Standards committee the first time C++ was standardized.

Dag Bruck proposed this extension, calling the base class "inherited." The proposal mentioned the multiple inheritance issue, and would have flagged ambiguous uses. Even Stroustrup was convinced.

After discussion, Dag Bruck (yes, the same person making the proposal) wrote that the proposal was implementable, technically sound, and free of major flaws, and handled multiple inheritance. On the other hand, there wasn't enough bang for the buck, and the committee should handle a thornier problem.

Michael Tiemann arrived late, and then showed that a typedef'ed super would work just fine, using the same technique that was asked about in this post.

So, no, this will probably never get standardized.

If you don't have a copy, Design and Evolution is well worth the cover price. Used copies can be had for about $10.

2 of 16
116

I've always used "inherited" rather than super. (Probably due to a Delphi background), and I always make it private, to avoid the problem when the 'inherited' is erroneously omitted from a class but a subclass tries to use it.

class MyClass : public MyBase
{
private:  // Prevents erroneous use by other classes.
  typedef MyBase inherited;
...

My standard 'code template' for creating new classes includes the typedef, so I have little opportunity to accidentally omit it.

I don't think the chained "super::super" suggestion is a good idea- If you're doing that, you're probably tied in very hard to a particular hierarchy, and changing it will likely break stuff badly.

🌐
Runestone Academy
runestone.academy › ns › books › published › csawesome › Unit9-Inheritance › topic-9-4-super.html
9.4. super Keyword — CSAwesome v1
super.method(); calls a superclass’ method (not constructors). The keyword super is very useful in allowing us to first execute the superclass method and then add on to it in the subclass.
🌐
Hacker News
news.ycombinator.com › item
How to Emulate the “super” Keyword in C++ | Hacker News
October 4, 2017 - As others have pointed out, putting the keyword in the base class is Highly Questionable · I've also seen inconsistency in various inheritance diagrams; sometimes the arrow points to the child, sometimes to the parent
🌐
Microsoft Learn
learn.microsoft.com › en-us › cpp › cpp › super
__super | Microsoft Learn
With the introduction of attributes that inject code, your code might contain one or more base classes whose names you may not know but that contain methods that you wish to call. // deriv_super.cpp // compile with: /c struct B1 { void mf(int) {} }; struct B2 { void mf(short) {} void mf(char) {} }; struct D : B1, B2 { void mf(short) { __super::mf(1); // Calls B1::mf(int) __super::mf('s'); // Calls B2::mf(char) } };
🌐
Edureka Community
edureka.co › home › community › categories › c++ › using super in c
Using super in C | Edureka Community
July 13, 2022 - The following phrase is part of my coding approach: class Derived : public Base { public : ... or is its current use through a typedef sufficien?
🌐
Cplusplus
cplusplus.com › forum › general › 4579
Inheritance and the keyword SUPER - C++ Forum
Given an object of type cat, calling feed() on that object would call cat::feed(). If feed() were not pure in the base, then given an object of type animal (and not cat), calling feed() on that object would call animal::feed(). Not sure if this is what you are asking because I don't do java.
🌐
LinuxQuestions.org
linuxquestions.org › questions › programming-9 › c-super-keyword-273766
c++ super keyword
Is super ( http://msdn.microsoft.com/library/de.../key_s-z_1.asp ) a microsoft specific keyword? More importantly, if I use it, will gcc recognize it?
Find elsewhere
🌐
Quora
quora.com › What-is-the-purpose-of-the-super-method-in-an-object-oriented-programming-language-like-C-or-Java
What is the purpose of the super() method in an object oriented programming language like C++ or Java? - Quora
Answer (1 of 2): It represents a call to the constructor of the super class, with any arguments required - possibly none - by that constructor. The super class constructor always needs to get called once from every subclass constructor, either ...
🌐
Fluent C++
fluentcpp.com › home › how to emulate the “super” keyword in c++
How to Emulate The "super" Keyword In C++ - Fluent C++
June 1, 2018 - And C++ doesn’t have a super or base keyword to designate “the base class”, like C# and Java do. One reason for this is that C++ supports multiple inheritance, which would make such a keyword ambiguous. But on the other hand, multiple inheritance is not used so often in C++. So how can a derived class designate its base in the case of single inheritance?
🌐
Fiveable
library.fiveable.me › ap-comp-sci-a › unit-9 › super-keyword › study-guide › KFSf1qj68MN8JgmRHWzC
Super Keyword - AP CSA Study Guide | Fiveable | Fiveable
Cram for AP Computer Science A – Inheritance with Fiveable Study Guides. Includes key concepts, notes, vocab, and practice quizzes.
🌐
Unreal Engine
forums.unrealengine.com › development › programming & scripting › c++
What i sthe Super keyword and how its work - C++ - Epic Developer Community Forums
August 30, 2018 - Hi. Can someone tell me how the Super keyword works? As I remember this is not how we call method from parent class in c++? pls help
🌐
Cprogramming
cboard.cprogramming.com › cplusplus-programming › 108276-cplusplus-equivalent-super.html
C++ equivalent of super
The second question would be how do I call the Base class's function without explicitly specifying the base class name (i.e. a dynamic reference, something to emulate "super")? Since you have "generic stuff" to do, the solution is to provide a protected virtual function that subclasses override if they want to do more than the "generic stuff", and then have the base class provide the "generic stuff" in a non-virtual function, e.g.,
🌐
Runestone Academy
runestone.academy › ns › books › published › csjava › Unit10-Inheritance › topic-10-4-super.html
10.4. super Keyword — CS Java
We’ve used super() before to call the superclass’ constructor. There are two uses of the keyword super: super(); or super(arguments); calls just the super constructor if put in as the first line of a subclass constructor.
Top answer
1 of 3
3

In addition to all the above, consider the following scenario:

  • You start out with these two classes.

     class A {
        int i = 20;
    
        A() {
            System.out.println("I am in constructor of the parent class");
        }
    }
    
    class B extends A {
        int i = 30;
    
        B() {
            System.out.println("I am in constructor of the subclass");
        }
    }
    
  • You compile both classes, it creates two class files: A.class and B.class

  • Now you change your mind and rewrite A:

     class A {
        int i = 10;
    
        A() {
            System.out.println("I am in constructor of the parent class");
        }
    }
    
  • You recompile A, so you get a new A.class, which you replace the old A.class with

Now the question is: how would B know that As initialisation code has changed? You haven't recompiled B, nor should you be required to do so. After all, B may already be packaged up in a different jar, maybe even in a different product you have no control over.*

The only reasonable way to support this case is for Bs constructor to start with calling As constructor and let A initialise itself.

*This may sound far-fetched at first, but this is exactly what happens when internal implementation details of JDK classes are changed. All the previously compiled Java applications in the world should run seamlessly with the new JDK.

2 of 3
4

Much of this is spelled out in the JLS section 15.11:

15.11.2 Accessing Superclass Members using super
The form super.Identifier refers to the field named Identifier of the current object, but with the current object viewed as an instance of the superclass of the current class.

The key word there is of the current object. If there is no current object, such as the case with a static method, you can't user the super method.


When it comes to the constructor, the super class is responsible for initializing its fields. This is necessary because there may be private fields within the super class that a subclass has no access to.

Furthermore, requiring the subclass to instantiate the state of the super class may require the subclass to have more information than necessary and also requires a tighter coupling between superclass and subclass than is desirable - any change to the fields in the superclass would require a change in all the subclasses. This is a bad thing.

Thus, you prevent this bad thing from happening by having the subclass call the constructor of the superclass when it is created.

🌐
W3Schools
w3schools.com › java › ref_keyword_super.asp
Java super Keyword
The most common use of the super keyword is to eliminate the confusion between superclasses and subclasses that have methods with the same name. To understand the super keyword, you should have a basic understanding of Inheritance and Polymorphism.
🌐
TutorialsPoint
tutorialspoint.com › equivalent-of-java-super-keyword-in-chash
Equivalent of Java Super Keyword in C#
It is used to invoke the superclass constructor from subclass. C# base keyword is used to access the constructors and methods of base class.
🌐
Linux Hint
linuxhint.com › emulate-super-keyword-cpp
How to Emulate the super Keyword in C++
Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
Sololearn
sololearn.com › en › Discuss › 1212983 › why-super-keyword-must-be-the-first-statement-in-constructor
Why "super" keyword must be the first statement in constructor | Sololearn: Learn to code for FREE!
If you don't write it down, it will get called implicitly to make sure the parent class exists. ... The superclass' [parent/ base] constructor needs to be called before the subclass' constructor.