Solved

Global CList

Posted on 1997-11-17
4
253 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

623 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