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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:11:24+00:00 2026-05-23T16:11:24+00:00

I made a program that has a class with static-only members in it in

  • 0

I made a program that has a class with static-only members in it in its own dedicated cpp/h file combo. The probably is that when I try to use these static members in my code, I’m getting “unresolved external” errors at the linker stage. I am remembering to include the h file in my cpp file that is getting the errors. I don’t understand. Is this the wrong design approach to take?

Basically i want some global objects that are part of a third party API to be available to my whole program, so I organized everything into one class and made everything a static member. I also made an empty private constructor to keep the class from being instantiated. Is this a sensible approach? The static members are all pointers and I tried to start out by allocating new objects and attaching each to the static poonters. Is here a problem with this approach?

Thanks!

  • 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-23T16:11:25+00:00Added an answer on May 23, 2026 at 4:11 pm

    Are you remembering to actually define the variable somewhere, instead of just declaring it in the header?

    Foo.hpp:

    #ifndef FOO_HPP
    #define FOO_HPP
    
    class Foo {
    public:
      static int bar;
    };
    
    #endif
    

    Foo.cpp:

    #include "Foo.hpp"
    
    int Foo::bar; // <-- This being the critical line.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm dynamically sub classing a generic type (filling it's contract) that has a generic
I have a text editor I made, which has been working perfectly for the
I just finished debugging a problem, where our program crashed on a production server,
I found this one question asking the same thing , however only the 'new'
I'm trying to designing a class and I'm having issues with accessing some of
I made the example below which enables a factory to pack objects with functionality,
I have a fairly large CRUD winform app that is set up to display
I've created a Windows Communication Foundation service (the appDomain in this case is a
I know prime finding is well studied, and there are a lot of different
I'm building a tiny webapplication in which our customers can update some details about

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.