Solved

Global CList

Posted on 1997-11-17
4
250 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

861 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