Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7532491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:28:10+00:00 2026-05-30T05:28:10+00:00

I hae written the following code: class Object { public: Object() {} }; template

  • 0

I hae written the following code:

class Object
{
   public:
   Object()
   {}
};

template <class T>
class Reg : public Object
{
    T val,val_new;
    public:
    Reg(T initval)
    {
    super( );
    val=initval;
    } 
};

The error in the code is

t.cpp: In constructor 'Reg<T>::Reg(T)':
Line 15: error: there are no arguments to 'super' that depend on a template parameter,
so a declaration of 'super' must be available
compilation terminated due to -Wfatal-errors.

How can i eliminate the error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:28:12+00:00Added an answer on May 30, 2026 at 5:28 am
    class Object
    {
    public:
       Object() {}
    };
    
    template <class T>
    class Reg : public Object
    {
        T val,val_new;
    public:
        Reg(T const& initval)
            : val( initval )
        {} 
    };
    

    There is no super in standard C++. Some compilers offer it as a language extension, but in standard C++ if you want a generic name for “the” base class, then you have to typedef it. For example, in class Reg you can typedef Object Base;.

    The construction : val( initval ) is a constructor initializer list, where essentially you call constructors of members and base classes, avoiding default construction.

    Finally, the const&, passing by reference, avoids time-consuming and memory-consuming copying of the actual argument; it’s another thing that’s different in C++ (compared to Java, which I’m assuming that you’re coming from).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have the following code to check for the text file called Doctors.txt
I hae the following CSS selector: .section h1, .section > div:first-child { background-color: #E5E5E5;
i hae a link like ( domain.com/jsapi?key=123456 ) hov can i get this key
Possible duplicate: why does the css min-width attribute not force a div to hae
In the http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html echo Main-Class: oata.HelloWorld>myManifest md build\jar jar cfm build\jar\HelloWorld.jar myManifest -C build\classes
I was wondering the following, if I have these two Models: Author Book And
I hae a form on my website which I've just built, im unsure on
I hae a very simple application. I create bubbles at the bottom of the
As I can't post code I'm asking this as a theoretical question, but giving
(1) a={'b':'bbbb','c':'ccc',....} (2) self.redirect('/tribes/view?b=' + a['b'] + '&c=' + a['c']) so i want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.