Solved

Lists in C++

Posted on 2000-03-26
6
186 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
6 Comments
 
LVL 5

Expert Comment

by:proskig
Comment Utility
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
Comment Utility
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
Comment Utility
Yes,
KangaRoo was two minutes earlier, I did check that there were no answers, I spent these two minutes for typing answer.

Igor
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 7

Expert Comment

by:KangaRoo
Comment Utility
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
Comment Utility
give us some more code
like the code od the CListe Class
0
 

Accepted Solution

by:
jamanat earned 100 total points
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

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. …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now