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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:17:18+00:00 2026-05-25T03:17:18+00:00

I have defined globally a list in one class as a pointer: class1.cpp type

  • 0

I have defined globally a list in one class as a pointer:

class1.cpp

type list[1000];
type *p_list = list;

Now I want to use this list and put some values into it. This should happen in another class, in a method

class2.cpp

mousePressEvent_from_class_2()
{
    p_list[counter].x = pos().x(); 
}

But the compiler is telling me that it doesn’t know p_list. How can I change that?

  • 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-25T03:17:19+00:00Added an answer on May 25, 2026 at 3:17 am

    The compiler needs to know that p_list is declared elsewhere. Put the following in class1.h or in class2.cpp (at file scope).

    extern type *p_list;
    

    The definition of type must also be visible in class2.cpp. Make sure the definition is in a header file (class1.h) and class2.cpp #includes this header.

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

Sidebar

Related Questions

I have defined a custom list template type for SharePoint . I install it
I have defined a custom Sharepoint list for special attributes related to a software
I have defined an interface in C++, i.e. a class containing only pure virtual
I have defined a class A and derived a new class B from A
In a C struct I have defined a function pointer as follows: typedef struct
My computer have a proxy server defined globally (in internet options configuration). I have
I have a class that I've been provided that I really don't want to
I have defined a personalizable property on a web part and I would like
I have defined a new dialog and its controls in an already existing resource
I have defined the global nls_date_format on Oracle 10.2 XE as follows: alter system

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.