?
Solved

Lists in C++

Posted on 2000-03-26
6
Medium Priority
?
191 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 200 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

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…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

752 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