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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:32:37+00:00 2026-05-30T11:32:37+00:00

This is for C++. Usually we have our function declaration in header file and

  • 0

This is for C++.

Usually we have our function declaration in header file and definition in source file.
Say we have a class A with some functions:

//< A.hpp
class A
{
public:
   virtual funcA();
   virtual funcB();
}

And we want to have a class inherit from A and override its functions.

//< childA.hpp
class childA
{
   virtual funcA();
   virtual funcB();
}

Everytime we change the declarations of funcA() funcB(), we need to copy-and-paste the new declarations to the child classes header files. If the inheritance chain is long, it’s quite bother.

I remember we don’t have this problem with Object-C, do we?

  • 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-30T11:32:38+00:00Added an answer on May 30, 2026 at 11:32 am

    You don’t need to copy a member function declaration to the child class’s header file unless you want to override it. In that case, I believe the main reason you’re required to declare it is to inform anyone reading your header file that the child class is providing a different implementation. In principle, the compiler can figure it out automatically, but it could be a real pain for a human to do the same thing manually.

    Note that in many cases, people reading your header files may not have access to the actual source code for the body (e.g., if it’s a proprietary library that is delivered to them as compiled objects), so they can’t just go look at the body to figure it out.

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

Sidebar

Related Questions

I have been seeing code like this usually in the start of header files:
We have a certain binary file in our git repository. Usually it's around 2MB
In a Python system for which I develop, we usually have this module structure.
I usually have my structure laid out something like this: <div id=all> <div id=page>
When performing many inserts into a database I would usually have code like this:
I usually do not have difficulty to read JavaScript code but for this one
I have read this post about how to test private methods. I usually do
I have had to do this several times, usually when trying to find in
I have this situation.... Client-initiated SOAP 1.1 communication between one server and let's say,
Our database drivers are usually copied under <jboss.home>\common\lib folder in JBoss 5.1 and this

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.