473,325 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

super

Hi,
A keyword "super" is used in C++ in classes. It is said that it is used for accessing base class from the derived class. But I am unable to understand its real purpose. Accessing just a base class doesn't serve the purpose of keeping a extra keyword. Can anyone explain it elaborately.

Thanks in advance.
Jul 31 '06 #1
4 12002
Banfa
9,065 Expert Mod 8TB
This sentence

Accessing just a base class doesn't serve the purpose of keeping a extra keyword.
Doesn't make sense.

However there is no "super" keyword in C++ are you thinking of Java? If you want to access a base class from a derived class you just use the base class as a prefix

Expand|Select|Wrap|Line Numbers
  1. class BaseClass
  2. {
  3. public:
  4.     void PrintMe();
  5.  
  6. }
  7.  
  8. class DerivedClass : public BaseClass
  9. {
  10. public:
  11.     void PrintMe();
  12.  
  13. }
  14.  
  15. void DerivedClass::PrintMe()
  16. {
  17.     cout << "In derived class" << endl;
  18.     BaseClass::PrintMe();
  19. }
  20.  
Jul 31 '06 #2
No no, the keyword "super" is there in C++. I am giving a link of MSDN where you can find the notes for it, but its only briefly given. I want an elaborate explanation.

http://msdn.microsoft.com/library/de.../key_s-z_1.asp

It is said that we can access any member of any base class through this keyword, but that can be done with the usual procedure of class also, then what is the purpose of this keyword.

Please go through the above link, "super" is there in C++.
Aug 1 '06 #3
Banfa
9,065 Expert Mod 8TB
It is a Microsoft specific extension of C++, i.e. not standard C++, it is clearly not required so it is not clear why they chose to add it (perhaps you better phone Bill Gates :D).

I guess they have put it in to aid people familiar with Java, however I would avoid using it if I where you.
Aug 1 '06 #4
It is a Microsoft specific extension of C++, i.e. not standard C++, it is clearly not required so it is not clear why they chose to add it (perhaps you better phone Bill Gates :D).

I guess they have put it in to aid people familiar with Java, however I would avoid using it if I where you.

Oh so "super" is a microsoft specific keyword for C++, since it was used in our project which is in microsoft language thatz why I was unable to understand it. Anyway I dont have Bill gates phone number(Ha ha ha...).
Thanks a lot.
Aug 1 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Kerim Borchaev | last post by:
Hello! Always when I use "super" I create a code duplication because class used as first arg to "super" is always the class where the method containing "super" was defined in: ''' class C:...
2
by: Clarence Gardner | last post by:
The super object is considered a solution to the "diamond problem". However, it generally requires that the ultimate base class know that it is last in the method resolution order, and hence it...
11
by: Nicolas Lehuen | last post by:
Hi, I hope this is not a FAQ, but I have trouble understanding the behaviour of the super() built-in function. I've read the excellent book 'Python in a Nutshell' which explains this built-in...
0
by: Michele Simionato | last post by:
Here is an idea for a nicer syntax in cooperative method calls, which is not based on Guido's "autosuper" example. This is just a hack, waiting for a nicer "super" built-in ... Here is example...
0
by: Delaney, Timothy C (Timothy) | last post by:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286195 This is a new version of super that automatically determines which method needs to be called based on the existing stack frames....
6
by: Steven Bethard | last post by:
When would you call super with only one argument? The only examples I can find of doing this are in the test suite for super. Playing around with it: py> class A(object): .... x = 'a'...
7
by: Kent Johnson | last post by:
Are there any best practice guidelines for when to use super(Class, self).__init__() vs Base.__init__(self) to call a base class __init__()? The super() method only works correctly in multiple...
7
by: Pupeno | last post by:
Hello, I have a class called MyConfig, it is based on Python's ConfigParser.ConfigParser. It implements add_section(self, section), which is also implemented on ConfigParser.ConfigParser, which I...
9
by: Mike Krell | last post by:
I'm reading Alex Martelli's "Nutshell" second edition. In the section called "Cooperative superclass method calling", he presents a diamond inheritance hierachy: class A(object): def...
4
by: ddtl | last post by:
Hello everybody. Consider the following code: class A(object): def met(self): print 'A.met' class B(A): def met(self):
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.