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

  • Home
  • SEARCH
  • 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 8679441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:58:24+00:00 2026-06-12T20:58:24+00:00

My parent class, Course, has the method addStudent(Student s). My child class, BetterCourse, inherits

  • 0

My parent class, Course, has the method addStudent(Student s). My child class, BetterCourse, inherits from Course. Every time I try to run BetterCourse.addStudent(s), I get the following error:

error: no matching function for call to
‘BetterCourse::addStudent(Student (&)())’ note: candidates are: void Course::addStudent(Student)

I understand it’s telling me addStudent() hasn’t been defined in BetterCourse and that it’s recommending I use the one present in the parent class, Course. This has me confused as the whole idea around inheritance is not needing to redefine inherited functions and variables.

Course is as follows:

#include <iostream>
#include <string>
#include "Student.h"

using namespace std;

class Course
{

    protected:
        string id;
        string name;

    public:
        Course();
        Course(string id, string name);     
        void addStudent(Student s);
};

Course::Course()
{
   //code
}

Course::Course(string id, string name)
{
   //code
}

void Course::addStudent(Student s) 
{
   //code
}

BetterCourse:

#include <iostream>
#include <string>
#include "Course.h"

using namespace std;

class BetterCourse : public Course
{
    public:
        BetterCourse(string id, string name) : Course(id,name){};
};
  • 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-06-12T20:58:26+00:00Added an answer on June 12, 2026 at 8:58 pm

    From your error it seems that you for the first time get to the ugliest part of C++.

    This:

    Student s();
    

    Is function declaration – not object definition. s type is Student (*)() so when you call:

    BetterCourse bc; 
    bc.addStudent(s);
    

    You get your error – you don’t have method to add functions returning Student.

    Define Student in the following ways:

    Student s;
    Student s {}; // new C++11 way
    Student s = Student(); // 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a parent class and child class (inherited from parent). In the child
I have a MustInherit Parent class with two Child classes which Inherit from the
I have a parent class which contains a child object. I am using set
I have a parent class Parent and a child class Child , defined thus:
Given the following classes: @XmlRootElement(name = parent) class Parent { private Child child; //
I am trying to access child class variables in parent class..can u suggest me
I have a class TChild derived from TParent. TParent has a property MyProp that
I have a parent/child relationship via our users table, with models as such: class
I have a parent class called Exam and that has many instances of a
I have one parent class, which is abstract class for now, for four different

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.