View Full Version : CPP..why make new objects?

03-24-2004, 07:04 AM
I'm reading about classes and instances and I dont think I understand why anyone would need to make new objects..Doesn't C++ have enough objects to make the cpp do pretty much anything you'd want to do?

03-25-2004, 12:14 AM
Think of it this way: All the objects that are generic enough and that can be used in a lot of places are already written and are available as standard libraries, or 3rd party libraries. All the objects that are specific to the scenario are the ones that are being written everyday by programmers.

For example: you are making a program to control a special device you made. lets say that the device makes baloons by taking rubber as input and several parameters, like color, design, etc to make its output. so you now have an object that represents this device. its members look like outputcolor, outputdesign, etc. Surely, no one else cares about this object.. you have to write it yourself!

03-26-2004, 11:09 AM
Very well said Unit!

Indeed they are very useful, you need new objects because CPP doesn't have the particular object for everything!

Like I've been making custom gui controls, I need to keep track of different properties like say if it's a button, the style, is it clicked? what color is it and what does it have written on it? Although, I tend to use structs more unless I need member functions..

What I really find useful with classes is derived an templated classes though, templated classes are very useful for lists and memory management and derived classes make making a wrapper for my controls like that of MFC easier.

C++ doesn't have built in objects really, they're all created in standard libraries as said ... You'll always need new objects.

[edit:] Welcome to the forums Unit :)

03-26-2004, 02:02 PM
Think if you want to have a list of employees. There is no employee class, but it would be useful to have an employee object for each employee to hold together their data and the methods to view and alter it too.

03-26-2004, 11:24 PM

Originally posted by Mhtml
[edit:] Welcome to the forums Unit :)
Thanks! I am not new to these forums though :) I was a regular member long time back, maybe 3 or 4 years back at wsabstract. I discontinued posting due to personal pressures, but I am back :thumbsup:

I lost all touch with Javascript, so I am lurking around posting only things that I know for sure :D

03-27-2004, 12:02 PM
lol :D ... well I'm sure given time you'll be back in the saddle so to speak :) ..