[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Lists in C++

Posted on 2000-03-26
6
Medium Priority
?
193 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Technology Partners: 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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

873 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