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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:55:17+00:00 2026-05-13T07:55:17+00:00

I have a little class called Stuff that I want to store things in.

  • 0

I have a little class called Stuff that I want to store things in. These things are a list of type int. Throughout my code in whatever classes I use I want to be able to access these things inside the Stuff class.

Main.cpp:

#include "Stuff.h"

int main()
{
    Stuff::things.push_back(123);
    return 0;
}

Stuff.h:

#include <list>

class Stuff
{
public:
    static list<int> things;
};

but I get some build errors with this code:

error LNK2001: unresolved external symbol “public: static class std::list<int,class std::allocator<int> > Stuff::things” (?things@Stuff@@2V?$list@HV?$allocator@H@std@@@std@@A) Main.obj CSandbox

fatal error LNK1120: 1 unresolved externals C:\Stuff\Projects\CSandbox\Debug\CSandbox.exe CSandbox

I am a C# guy, and I am trying to learn C++ for a side project. I think that I don’t understand how C++ treats static members. So please explain what I have got wrong 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-05-13T07:55:17+00:00Added an answer on May 13, 2026 at 7:55 am

    Mentioning a static member in a class declaration is a declaration only. You must include one definition of the static member for the linker to hook everything up properly. Normally you would include something like the following in a Stuff.cpp file:

    #include "Stuff.h"
    
    list<int> Stuff::things;
    

    Be sure to include Stuff.cpp in your program along with Main.cpp.

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

Sidebar

Related Questions

I have a little issue on what sequence things are being called when adding
I have a class called GraphView that extends UIView that basically draws a small
I have a class that can be called either from a GUI or form
I have problem in C#. I have a list box and a class called
I have little working knowledge of python. I know that there is something called
In my little scratch built flex game framework, I have defined a class called
Case One Say you have a little class: class Point3D { private: float x,y,z;
I have a silly, little class FileSystemSize which can be used both as an
I have a little console C# program like Class Program { static void main(string
I have a class called Entry. This class as a collection of strings called

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.