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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:22:58+00:00 2026-05-14T08:22:58+00:00

I’ve just started with C++, and maybe there’s something that I’m doing wrong here,

  • 0

I’ve just started with C++, and maybe there’s something that I’m doing wrong here, but I’m at a loss. When I try to build the solution, I get 4 LNK2005 errors like this one:

error LNK2005: "public: double __thiscall Point::GetX(void)const " (?GetX@Point@@QBENXZ) already defined in CppSandbox.obj

(there’s one for each get/set method, and they all allegedly occur in Point.obj)

And then finally this error:

error LNK1169: one or more multiply defined symbols found

Which reportedly occurs in CppSandbox.exe. I’m not sure what causes this error – it appears to happen when I build or rebuild the solution… Really at a loss, to be honest.

The three files below are the entirety of what I added to the default VS2010 blank project (they’re copied in their entirety). Thanks for any help you can offer.

Point.h

class Point
{
public:
    Point() 
    { 
        x = 0; 
        y = 0; 
    };
    Point(double xv, double yv) 
    { 
        x = xv;
        y = yv; 
    };

    double GetX() const;
    void SetX(double nval);

    double GetY() const;
    void SetY(double nval);

    bool operator==(const Point &other)
    {
        return GetX() == other.GetX() && GetY() == other.GetY();
    }

    bool operator!=(const Point &other)
    {
        return !(*this == other);
    }

private:
    double x;
    double y;
};

Point.cpp

#include "Point.h"

double Point::GetX() const
{
    return x;
}

double Point::GetY() const
{
    return y;
}

void Point::SetX(double nv)
{
    x = nv;
}

void Point::SetY(double nv)
{
    y = nv;
}

CppSandbox.cpp

// CppSandbox.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include "Point.cpp"

int main()
{
    Point p(1, 2);
    Point q(1, 2);
    Point r(2, 3);

    if (p == q) std::cout << "P == Q";
    if (q == p) std::cout << "Equality is commutative";
    if (p == r || q == r) std::cout << "Equality is broken";

    return 0;
}
  • 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-14T08:22:58+00:00Added an answer on May 14, 2026 at 8:22 am

    The problem is in CppSandbox.cpp:

    #include "Point.cpp"
    

    You are including the cpp file instead of the header file, so its contents are compiled twice and everything in it is therefore defined twice. (It’s compiled once when Point.cpp is compiled, and a second time when CppSandbox.cpp is compiled.)

    You should include the header file in CppSandbox.cpp:

    #include "Point.h"
    

    Your header file should also have include guards.

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.