Solved

Global CList

Posted on 1997-11-17
4
245 Views
Last Modified: 2010-04-10
Hi there,
Is there a way to declare a global CList??
If yes, how do you declare this CList in other modules??
eg.
struct myStruct{
           CString var1;
           int var2;
          };

CList<myStruct,myStruct>list_struct;
CList<CString,CString>list_str;

so in this case, how do I declare these 2 list in other "*.h" files?
I am using MSVC++ 4.0

Thanks.
0
Comment
Question by:elv
  • 2
  • 2
4 Comments
 

Author Comment

by:elv
ID: 1173409
Adjusted points to 100
0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 100 total points
ID: 1173410
>Is there a way to declare a global CList??

Yes

>If yes, how do you declare this CList in other modules??
>eg.
>struct myStruct{
> CString var1;
> int var2;
> };
>CList<myStruct,myStruct>list_struct;
>CList<CString,CString>list_str;
>
>so in this case, how do I declare these 2 list in other "*.h"
>files?

Just like that - but put an extern in front for the .h

0
 

Author Comment

by:elv
ID: 1173411
ie in the other .h files,

extern CList<myStruct,myStruct>list_struct;
extern CList<CString,CString>list_str;
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1173412
That should be it.

In the defining .cpp you would have these lines WITHOUT the 'extern' in front - that then make the line a 'definition' instead of a 'declaration'.


0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now