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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:09:06+00:00 2026-05-27T11:09:06+00:00

I have this class with variable configuration parameters. I want to include it in

  • 0

I have this class with variable configuration parameters. I want to include it in other classes: JugadorHumano, JugadorIA, Main, PartidaClasica, PartidaMision.

#pragma once

class Configuracion
{
public:
    static int MAX_ATAQUES;
    static int DIV_TERRITORIOS;
};

int Configuracion::MAX_ATAQUES = 5;
int Configuracion::DIV_TERRITORIOS = 3;

What I want is to be able to modify or read the values from the other classes. I can’t declare a static variable and define it in the declaration. I can’t let that variables without definition either because I get “Unresolved External” errors.

1>JugadorIA.obj : error LNK2005: "public: static int Configuracion::MAX_ATAQUES" \
         (?MAX_ATAQUES@Configuracion@@2HA) already defined in JugadorHumano.obj
1>JugadorIA.obj : error LNK2005: "public: static int Configuracion::DIV_TERRITORIOS" \
         (?DIV_TERRITORIOS@Configuracion@@2HA) already defined in JugadorHumano.obj
1>Main.obj : error LNK2005: "public: static int Configuracion::MAX_ATAQUES" \
         (?MAX_ATAQUES@Configuracion@@2HA) already defined in JugadorHumano.obj
1>Main.obj : error LNK2005: "public: static int Configuracion::DIV_TERRITORIOS" \
         (?DIV_TERRITORIOS@Configuracion@@2HA) already defined in JugadorHumano.obj
1>PartidaClasica.obj : error LNK2005: "public: static int Configuracion::MAX_ATAQUES" \
         (?MAX_ATAQUES@Configuracion@@2HA) already defined in JugadorHumano.obj
1>PartidaClasica.obj : error LNK2005: "public: static int Configuracion::DIV_TERRITORIOS" \
         (?DIV_TERRITORIOS@Configuracion@@2HA) already defined in JugadorHumano.obj
1>PartidaMision.obj : error LNK2005: "public: static int Configuracion::MAX_ATAQUES" \
         (?MAX_ATAQUES@Configuracion@@2HA) already defined in JugadorHumano.obj
1>PartidaMision.obj : error LNK2005: "public: static int Configuracion::DIV_TERRITORIOS" \
         (?DIV_TERRITORIOS@Configuracion@@2HA) already defined in JugadorHumano.obj
1>D:\Leire\My Dropbox\Carpetas compartidas\Compartidos Victor\Practicas POO II\P3\P3M10\Debug\P3M10.exe : fatal error LNK1169: one or more multiply defined symbols found

What should I do to avoid this redefinition I get? I can’t figure it out and I can’t find a similar problem.

  • 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-27T11:09:07+00:00Added an answer on May 27, 2026 at 11:09 am

    You should write the definitions in the cpp file, otherwise, once you include your header file into more than one C++ file(translation unit), you’ll get redefinition errors. And #pragma once operates only within one translation unit. So you need a Configuration.cpp file with the following contents

    #include "Configuracion.h"
    
    int Configuracion::MAX_ATAQUES = 5;
    int Configuracion::DIV_TERRITORIOS = 3;
    

    Also, if your class contains only static member, you have the option of considering having a namespace instead of a class.

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

Sidebar

Related Questions

I have two classes, one of them is a configuration class. Inside of this
I have a variable declared like this in a class: Entity *array[BOARD_SIZE][BOARD_SIZE]; I need
Suppose that I have an integer variable in a class, and this variable may
I have this PHP class, whose purpose is to fetch some configuration data from
I have one main class main, which I use to store the configuration and
I currently have my PHP class variables set up like this: class someThing {
I have this class called Table: class Table { public string Name { get
I have this class. public class Foo { public Guid Id { get; set;
i have this class called MemoryManager, it is supposed to implement a simple smart
I have this class: class View(object): def main_page(self, extra_placeholders = None): file = '/media/Shared/sites/www/subdomains/pypular/static/layout.tmpl'

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.