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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:11:15+00:00 2026-06-15T05:11:15+00:00

I have a base class Point from which I inherit in Point3D . However,

  • 0

I have a base class Point from which I inherit in Point3D. However, for some reason class Point must always return Point3D for the operation add, so I include it in my includes.

This is my class Point:

#ifndef POINT_H
#define POINT_H

#include "Point3D.hpp"

class Point{

  public:
    Point(double, double, double);

    void print() const;
    Point3D add( const Point& );

  protected:
    double mX;
    double mY;
    double mZ;

};

#endif

In my class Point3D, I know I will not yet have encountered the definition of Point when I will first be called (because Point3D is included in the Point header), so I define class Point;, then I define the parts I will use of Point:

#ifndef POINT3D_H
#define POINT3D_H

#include <iostream>
#include "Point.hpp"  // leads to the same error if ommitted

class Point;    

class Point3D : public Point {

  public:
        Point3D(double, double, double);
        void print() const ;
        Point3D add(const Point&);
};

#endif

However, this is not working. When I compile it, it gives me the following error:

./tmp/Point3D.hpp:9:24: error: base class has incomplete type
class Point3D : public Point {
                ~~~~~~~^~~~~
./tmp/Point3D.hpp:7:7: note: forward declaration of 'Point'
class Point;
      ^
1 error generated.

The question here would say to remove the include #include "Point.hpp" from my Point3D declaration. However, doing so leads to the same result, and I think the header-guards would basically accomplish the same thing.

I’m compiling with clang.

  • 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-15T05:11:16+00:00Added an answer on June 15, 2026 at 5:11 am

    You can’t inherit from an incomplete type. You need to structure your code as follows:

    class Point3D;
    
    class Point
    {
        // ...
        Point3D add(const Point &);
        // ...
    };
    
    class Point3D: public Point
    {
        // ...
    };
    
    Point3D Point::add(const Point &)
    {
        // implementation
    }
    

    Function return types may be incomplete, which is why your class definition of Point works like this.

    I trust you can figure out how to split that across header and source files. (For example, the first two parts can go in Point.hpp, the third in Point3D.hpp which includes Point.hpp, and the final implementation can go in Point.cpp which includes Point.hpp and Point3D.hpp.)

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

Sidebar

Related Questions

I have a base class IStructure which is derived by many classes. Some of
I have a base class: class motorcycle { public: virtual int speed() { return
I have a base class ( car ) and a class that inherit the
I have a base class called Panel, where some information about a window is
Basically, I have a pure virtual class Base, and a concrete class Derived which
I have a base class line which has a child class arc (note that
I have an abstract base class (Comparable) with Date and Time virtually inheriting from
Here's the situation. I have a base class which implements a method that accepts
I have a base class in C# which is like so Class A {
I have a base class Node which contains a list of child nodes. Node

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.