Computing.Net > Forums > Programming > What is an initialization list

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

What is an initialization list

Reply to Message Icon

Original Message
Name: nataku954
Date: April 6, 2005 at 12:20:13 Pacific
Subject: What is an initialization list
OS: XP Pro
CPU/Ram: Pentium M 1.5/512
Comment:

Okay im probably just being retarded...but i keep getting docked points on my C++ programs for not having initialization lists. The thing is i dont recall my prof going over them and if he did he called them something different. Ive got a few classes that require me to initialize their private data members such as item ID and item name...can someone give me an example of what this might look like so i can see what im doing wrong.


Report Offensive Message For Removal


Response Number 1
Name: borelli35
Date: April 11, 2005 at 00:34:33 Pacific
Reply: (edit)

====================================================================
This should be nothing more than a run of assignment statements for your data members:

object::member==value;
.
.
.
etc...

I think they are forcusing on it because C++ doesn't do any default initializations on variables and object data members and this can actually cause a tremendous number of problems for many in-experienced programmers. In this case I would agree with them because I've seen myself create the same error in programming many times and have seen the results. It's not so common now but since you can't predict the results, it's hard to prevent unless you have each and every constructor initialize your data members.

borelli35


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History




Data Recovery Software