Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Lists in C++

Posted on 2000-03-26
3
Medium Priority
?
182 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
3 Comments
 
LVL 7

Accepted Solution

by:
KangaRoo earned 400 total points
ID: 2660024
Is that all relevant code?? The dot's indicate there is more that is not shown and from what is shown, there is nothing to tell.

At first glance (without seeing the dots) it would seem that SCList is not pointing at anything at all. But as said, there is too little code.
0
 
LVL 1

Expert Comment

by:yarond
ID: 2660053
KangaRoo seems to have the right answer. it seems you don't allocate anything to SCList.
The member SCList is CEnsemble is a POINTER to CListe object, and not an object in itself.
Try doing something like "SCList = new CListe" before you try to run a member function of it.
The reason the code made an illegal operation is that you just tried to run a random bit of code since SCList contained meaningless junk that your code took as an object's address.
BTW it could be a good idea to use the standard naming conventions when you write code, to avoid these things. If you'd call you pointer pList for example, it would be much more obvious to you that it's just a pointer...
0
 

Expert Comment

by:YuraPhink
ID: 2660523
KangaRoo & Yaron:
if this was the error because of not allocated place in SCList then I don't think it would give such an error.
For example, in VC++ it usually says :
"...
the memory ...:... could not be read
OK to close
CANCEL to debug
"

But this is really good idea (!)
to show more code out of this program.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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 viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.
Suggested Courses

618 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