Solved

Lists in C++

Posted on 2000-03-26
6
190 Views
Last Modified: 2010-04-02
I have a list named CListe of objects from CEnsemble, and declared as follows:

class CListe; //forward declaration

class CEnsemble
{
...
  CListe *SCList;
...
}

class CListe
{
...
}

As you can see, there´s a list inside each element which compose the list.

I try to initialize the list inside each element in the CEnsemble´s contructor, as follows:

CEnsemble::CEnsemble(){    
   ...
   SCList->init();
}

But when I try to run the program, I get an error in this initialization:

"This program has performed an illegal operation and will be shut down. If the problem persistes...  Close/Debug/Details"

This error has nothing to do with the init method itself, since I get the error even for very simple methods.

HELP!!!!
0
Comment
Question by:caiman23
[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
6 Comments
 
LVL 5

Expert Comment

by:proskig
ID: 2660029
Hi,
The problem is obviously in fact that you do not create CListe object. So before running init you should call CListe constructor like: SCList = new SCList(...);
Also note that you posted this question twice.

Regards,
Igor
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2660120
Hey, I was first (check the other Q), though it doesn't really matter.

As I mentioned, this is a likely cause of the problem, but one can't be sure because the code given is incomplete.
0
 
LVL 5

Expert Comment

by:proskig
ID: 2660585
Yes,
KangaRoo was two minutes earlier, I did check that there were no answers, I spent these two minutes for typing answer.

Igor
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:KangaRoo
ID: 2660665
Happens all the time, and as I said, no problem.

I'm still curious about the rest of the code. The dots indicate some of it has been left out and what's left is too little.
0
 
LVL 1

Expert Comment

by:ntdragon
ID: 2661665
give us some more code
like the code od the CListe Class
0
 

Accepted Solution

by:
jamanat earned 100 total points
ID: 2677290
Hey if u want another solution u can try this :-

class CListe
{
....
  int data;
  CListe *SCList;
....
}

CEnsemble::CEnsemble(){      
   ...
   SCList = NULL;
}

And just in the main declare an object of the class  to create the list

main()
{
    CListe list;
......
}

you can access the elements like:-

     int a = list->data;

try this and tell me the results.
if u have any probs. please contact me at jamanat@usa.net


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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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 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.
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.

691 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