Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Question on Sty...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 45805 of 45898
Post > Topic >>

Question on Style regarding initialization for inter-working classes

by nomail@[EMAIL PROTECTED] May 7, 2008 at 10:25 PM

I have a project in which I created a base class with an inherited
framework regarding a machine Environment, and another class that will
output results to a file.

The Environment class is a base class which is machine dependent, so
all inherited classes basically describe the type of machine.
Initialization for these classes basically determines that the PATH is
set correctly, environment variables exist, etc.

I decided to seperate the Printing/Output functionality from the
Environment, in order to hide directory creation from the environment,
and  just in case there needs to be some inherited classes for output
(instead of printing ASCII, I could output in HTML, or something).

The Output class has 2 constructors, a default, and one that takes
a string which determines an output directory.

The Environment class has 2 constructors, a default, and another
that takes an int for debugging.

Anyway, the Environment class will use the Output class to create
some reports. The output class won't be used for any other class,
so I guess it requires an Environment.

The question is, should the Environment class hold an instance of
the Output class, or just a pointer?  

If it had an instance, then I would need to create new constructors
in the Environment class in order to pass the string. This seems
kinda clunky, as now I have modified the environment in order to
appease some other class.   It does have the advantage of
initialization of all classes at once.

The alternative would be for the Environment class to use a pointer to
the Output class, but the Output class would have to initialized
outside the environment class, and then the pointer set.  From a 
program perspective, this just takes a couple of extra steps,
but I need to make sure that the pointer is always set.

I may have already answered my question if I want inheritance
for the Output class (the pointer method would work better), but
I was wondering in terms of style if there is a better
style/method/whatever.
       ---- Posted via Pronews.com - Premium Corporate Usenet News
Provider ----
http://www.pronews.com
offers corporate packages that have access to
100,000+ newsgroups




 2 Posts in Topic:
Question on Style regarding initialization for inter-working cla
nomail@[EMAIL PROTECTED]   2008-05-07 22:25:39 
Re: Question on Style regarding initialization for inter-working
=?ISO-8859-1?Q?Marcel_M=F  2008-05-08 09:12:35 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 6:45:56 CDT 2008.