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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:59:59+00:00 2026-05-25T23:59:59+00:00

I’m sure this question has been asked before, but I can’t seem to find

  • 0

I’m sure this question has been asked before, but I can’t seem to find it.

I have two classes, Vector and Point.

The files are as such (a bit repetitive):

vector.h:

#include <math.h>
#include <stdlib.h>

class Vector {
  friend class Point;

  public:
    ...

    Vector(Point); // Line 16

vector.cpp:

#include <math.h>
#include <stdlib.h>

#include "vector.h"

...

Vector::Vector(Point point) { // Line 29
  x = point.x;
  y = point.y;
  z = point.z;
}

point.cpp and point.h look mostly the same, except you swap vector with point in the definitions.

I include them as such:

#include "structures/vector.cpp"
#include "structures/point.cpp"

When I compile, I get this error:

structures/vector.h:16:17: error: field ‘Point’ has incomplete type
structures/vector.cpp:29:15: error: expected constructor, destructor, or type conversion before ‘(’ token

I think this error is saying that Point hasn’t been declared yet, but when I declare it inside of vector.h by importing point.cpp, I get a huge pile of errors.

Could anyone shed some light on this problem?

Thank you!


Upon applying @ildjarn’s suggestions, those errors went away and I am left with this single one:

structures/vector.h:16:18: error: expected ‘)’ before ‘const’

And the line:

Vector(Point const);

I define it like so in the .cpp file:

Vector::Vector(Point const &point) {
  • 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-26T00:00:00+00:00Added an answer on May 26, 2026 at 12:00 am
    1. You shouldn’t be including .cpp files, you should be including the .h files.
    2. vector.cpp needs #include "point.h" and (presumably) point.cpp needs #include "vector.h".
    3. A forward declaration is only sufficient if you’re not doing anything that requires the type’s size or interface. Because Vector‘s constructor is taking a Point by value, its size must be known; change Vector‘s constructor to take the Point by const reference instead and a forward declaration will remain sufficient.
    4. Your headers need #include guards (or #pragma once if you don’t mind not being 100% portable).

    EDIT (in response to OP’s edit):

    Your declaration and definitions now mismatch — i.e., your definition is correct but your declaration needs Point const& rather than just Point const.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
Does anyone know how can I replace this 2 symbol below from the string
I have just tried to save a simple *.rtf file with some websites and

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.