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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:18:42+00:00 2026-06-16T13:18:42+00:00

Inside General.h #ifndef GENERAL #define GENERAL namespace counternamespace{ int upperbound; int lowerbound; } #endif

  • 0

Inside General.h

#ifndef GENERAL
#define GENERAL
namespace counternamespace{
    int upperbound;
    int lowerbound;
}
#endif

Inside Analyzer.h

#ifndef ANALYZER
#define ANALYZER
#include"General.h"

class Analyzer
{
public :
     int var ;
     int func();
};
#endif

Inside Test.h

#ifndef TEST
#define TEST
#include"Analyzer.h" //Error
class Test2
{
public:
    Test2(void);

public:
    ~Test2(void);
};
#endif

In the above code when I don’t add Analyzer inside Test.h everything is working fine. But after adding its showing the following linker error.

1>Test2.obj : error LNK2005: "int counternamespace::lowerbound" (?lowerbound@counternamespace@@3HA) already defined in Analyzer.obj
2>Test2.obj : error LNK2005: "int counternamespace::upperbound" (?upperbound@counternamespace@@3HA) already defined in Analyzer.obj

I have added the #ifndef/#endif. Then where I am doing the mistake? Can anyone please let me know?

  • 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-16T13:18:44+00:00Added an answer on June 16, 2026 at 1:18 pm
    Inside General.h
    
    #ifndef GENERAL
    #define GENERAL
    namespace counternamespace{
        extern int upperbound;
        extern int lowerbound;
    }
    #endif
    
    Inside General.cpp
    
    #include"General.h"
    using namespace counternamespace ;
    int counternamepace::upperbound = 12;
    int counternamepace::lowerbound = 12;
    

    Then do whatever needed .

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

Sidebar

Related Questions

I am trying to use a method inside class, from another class. namespace Crystal.Utilities
Can I set variables inside if-construct? In general, where is it allowed to set
in general i will use expr inside shell scripts for doing arithmetic operations. is
I can use partial template specialization inside class declaration template<class T1, class T2> struct
How do I add a controller-specific menu (or div) inside a general application layout
I know the general problem of Can't create handler inside thread that has not
General Info: Aspx page holds an Ascx User control. Inside the User control, the
I have a div general which is centered on the page. Inside I have
Just a general question about what the best practice is: public void Foo() {
I'm trying to write a general COLDFUSION pageheader template, which I want to include

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.