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 209477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:55:08+00:00 2026-05-11T17:55:08+00:00

I seem to be having a very frustrating time with an inherited class calling

  • 0

I seem to be having a very frustrating time with an inherited class calling an explicit superclass constructor. I just can’t seem to get the syntax right!

All the examples I have seen on the matter so far do not separate out the header and in-line class definition (using {}’s) from forward-declarations with a header file, so I’m not sure of how to cover the syntax between the .h and .cc files. Any help would be appreciated!

Here is the error the compiler gives me (gcc) :

serverconnection.h: In
constructor
“ServerConnection::ServerConnection(std::string,
std::string)”: serverconnection.h:25:
error: expected `{‘ at end of input
serverconnection.cc: At global scope:
serverconnection.cc:20: error:
redefinition of
“ServerConnection::ServerConnection(std::string,
unsigned int, short unsigned int,
PacketSender*, int)”
serverconnection.h:25: error:
“ServerConnection::ServerConnection(std::string,
unsigned int, short unsigned int,
PacketSender*, int)” previously
defined here serverconnection.cc: In
constructor
“ServerConnection::ServerConnection(std::string,
std::string)”: serverconnection.cc:20:
error: no matching function for call
to “Connection::Connection()”

I understand that it is trying to call the default Connection constructor, Connection(), as it just doesn’t understand my syntax.

Here is the code:

connection.h :

class Connection {
    public:
       Connection(string myOwnArg);
};

connection.cc :

#include "connection.h"
Connection::Connection(string myOwnArg) {
     //do my constructor stuff
}

serverconnection.h :

#include "connection.h"
class ServerConnection : public Connection {
    public:
       ServerConnection(string myOwnArg, string superClassArg) : Connection(superClassArg);
};

serverconnection.cc :

#include "serverconnection.h"
#include "connection.h"
ServerConnection::ServerConnection(string myOwnArg, string superClassArg) {
     //do my constructor stuff
}

Thanks so much in advance!

  • 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-11T17:55:08+00:00Added an answer on May 11, 2026 at 5:55 pm

    You don’t put the initializer list in the class declaration, but in the function defininition. Remove it from the header, and in your .cc file:

    #include "serverconnection.h"
    #include "connection.h"
    
    ServerConnection::ServerConnection(string myOwnArg, string superClassArg) : Connection(superClassArg) {
         //do my constructor stuff
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I seem to be having a very simple problem but I can't wrap my
I'm having this very weird problem, and I can't seem to figure it out.
I'm having a very odd problem that I can't seem to track down. Any
I'm having a very strange problem. When I log stacktraces, they seem to be
I’m having some difficulties with two queries. I can get some of the information
I seem to be having very annoying problems, I have found a brilliant paginations
I am writing a very small wordpress plugin but I seem to be having
Having some odd behavior I'd love some feed back on as I can't seem
I'm having a problem that I can't seem to figure out, though I'm not
I seem to be having a very odd problem with my iPhone project in

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.