Solved

Global CList

Posted on 1997-11-17
4
251 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

756 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