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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:45:05+00:00 2026-06-13T20:45:05+00:00

I have a basic file I’m attempting to use. #ifndef POINT_GUARD #define POINT_GUARD //——————————————————————————

  • 0

I have a basic file I’m attempting to use.

#ifndef POINT_GUARD
#define POINT_GUARD

//------------------------------------------------------------------------------

struct Point {
    int x, y;
    Point(int xx, int yy) : x(xx), y(yy) { }
    Point() :x(0), y(0) { }
};

//------------------------------------------------------------------------------

inline bool operator==(Point a, Point b) { return a.x==b.x && a.y==b.y; } 

//------------------------------------------------------------------------------

inline bool operator!=(Point a, Point b) { return !(a==b); }

//------------------------------------------------------------------------------

#endif // POINT_GUARD

Notice that it’s wrapped in a guard. Now this is imported into two different files. I’m getting an error, though.

It complains as soon as it hits struct Point that it’s a “Redefinition of Point”. Any ideas what could be happening here?

  • 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-13T20:45:07+00:00Added an answer on June 13, 2026 at 8:45 pm

    I can’t reproduce the error with the input given. I placed your code in test.h, and wrote this for test.cpp:

    #include "test.h"
    #include "test.h"
    

    Running g++ -Wall -c test.cpp produces no errors or warnings, and running it through the pre-processor shows that struct Point is declared only once, so the guard is working.

    I’d guess there’s a declaration with the same name somewhere else, outside of the code you quoted?

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

Sidebar

Related Questions

I have basic *.xib file, which have NSView. How can I use another nib
I have a VC++ application and in my application i have some basic file
I have some basic jquery code sitting in the header of the header file
i have a really basic java program just one .java/.class file (.java uncompiled .class
Let's say I have a text file of basic mathematical functions. I want to
I have a website that uses basic ASP.Net forms authentication. In the web.config file
So I have a basic application descriptor file for my AIR app. It looks
im new to php. I have a basic unlink php file which deletes a
I have basic issue that i don't understand, we use HEAT to consume directory
I have a basic png file with two colors in it, green and magenta.

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.