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

  • Home
  • SEARCH
  • 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 8304497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:51:49+00:00 2026-06-08T17:51:49+00:00

error C2071: ‘Lexicon::list’ : illegal storage class I have a class that reads a

  • 0

error C2071: ‘Lexicon::list’ : illegal storage class

I have a class that reads a bunch of strings into memory and then provides functions that allow applying operations on those strings and their relationships. As part of this I’d like to have a shared memory between the main.cpp where some of the operations are initiated and the class where the operations are completed. For this, in a previous post, it was suggested to use an extern type. But, now there is an error. How do I resolve this error and have a memory space shared by several classes?

in lexicon.h

    #ifndef _lexicon_h
    #define _lexicon_h

    #include <string>
    #include <vector>

    using namespace std;

    class Lexicon {
    public:
    Lexicon();
    ~Lexicon();

    extern vector<vector<string>> list;

    void buildVectorFromFile(string filename, vector<vector<string>> &list, int v, int h);

    private:
    struct charT { char letter; nodeT *next;};
    };
    #endif

in main.cpp

#include <string>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>

#include "lexicon.h"  

void buildVectorFromFileHelper (Lexicon & lex)
    {
        vector<vector<string>> list;
        lex.buildVectorFromFile("ASCII.csv", list, 200, 2); //build 2x200 vector list
    }
  • 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-08T17:51:51+00:00Added an answer on June 8, 2026 at 5:51 pm

    The rules of an extern memory is explained here in this daniweb thread; the comment there is that yes, this should be simple but it is somehow not intuitive. The gist is that the memory is globally declared with the extern prefix in .cpp file A and then to reuse the memory in cpp B, globally declare it again in .cpp file B.

    I think Luchian_Grigore and @jahhaj were getting there but we had either just not found the words for me to understand or they were still finding the words to explain.

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

Sidebar

Related Questions

Error creating bean with name 'sessionFactory' defined in class path resource [ApplicationContext.xml]: Invocation of
Error I have a web app with a mass uploader (Plupload) for photos and
Im getting an error that is really frustrating me in my C program. the
So I have a simple struct used for template definitions. template<class T> struct EventListener
I'm running against this error: int temp = 0789; error C2041: illegal digit '8'
I have a simple code below: class B; class A{ B b; }; class
I am getting C++ Compiler error C2371 when I include a header file that
template <class M, class A> class C { std::list<M> m_List; ... } Is the
Can we have a statement that calls a constructor, and does nothing with it?
I am trying to implement a function class, but got a error of redefinition.

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.