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
Solved

Lists in C++

Posted on 2000-03-26
6
188 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
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
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.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Quicksort a dynamic deque 33 73
How do I save this device context as a .bmp or a picture of some kind? 2 64
Beginner to Unreal Engine 4 5 94
Precision Problem in C++ 7 43
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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.

791 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