LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-04-2005, 12:26 PM   #1
kuna
LQ Newbie
 
Registered: Dec 2004
Location: Canada
Posts: 7

Rep: Reputation: 0
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?
 
Old 01-04-2005, 01:30 PM   #2
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
A quick test reveals this:

Code:
#include <iostream>

using namespace std;

class A
{
    public:
        virtual void Test() { cout << "A::Test()" << endl; }
};

class B : public A
{
    public:
        void Test()
        {
            super::Test();
            // This would be the normal way to do this:
            A::Test();
            cout << "B::Test()" << endl;
        }
};

int main()
{
    A* p = new B();

    p->Test();

    delete p;

    return 0;
}
Code:
$ g++ -o blah blah.cpp
blah.cpp: In member function `virtual void B::Test()':
blah.cpp:16: error: `super' undeclared (first use this function)
blah.cpp:16: error: (Each undeclared identifier is reported only once for each
   function it appears in.)
blah.cpp:16: error: parse error before `;' token
So, the answer is no the GNU compiler doesn't support that. It is likely a MS only keyword. Comment out that line, and you get this:

Code:
$ g++ -o blah blah.cpp
$ ./blah
$ ./blah
A::Test()
B::Test()
 
Old 01-04-2005, 01:43 PM   #3
Proud
Senior Member
 
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794

Rep: Reputation: 116Reputation: 116
Have you tried __super?
 
Old 01-04-2005, 01:49 PM   #4
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
Nope, good point. But now I did and get basically the same result.

Code:
blah.cpp: In member function `virtual void B::Test()':
blah.cpp:16: error: `__super' undeclared (first use this function)
blah.cpp:16: error: (Each undeclared identifier is reported only once for each
   function it appears in.)
blah.cpp:16: error: parse error before `;' token
BTW, this is with GCC 3.3.3 for Cygwin...
 
Old 01-04-2005, 07:22 PM   #5
leonscape
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Debian SID / KDE 3.5
Posts: 2,313

Rep: Reputation: 48
This is a MS only keyword. It was rejected from the standard, since it was felt that it added very little, and tended to confuse what was actually being called.

You can acheive a similar result from using typedef's and RTTI. ( Which is probably what the MS compiler is doing. ) You'd think they'd implement the standards betters, before adding there own cruft.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Gentoo (masked by: missing keyword) Jonatoon Linux - Software 7 01-07-2009 03:47 AM
nfs write == super slow; read == super fast - problem? BrianK Linux - Networking 4 08-23-2007 10:59 PM
cvs keyword sustitution blackzone Programming 1 08-08-2004 09:47 AM
Redhat: vi keyword highlights hamster Linux - General 8 04-30-2003 06:27 AM
keyword list loads only 73% marksstroud Linux - Distributions 2 06-11-2002 10:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration