Solved

Lists in C++

Posted on 2000-03-26
3
174 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 100 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

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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 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.

726 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