How to create instance of class that get data from 2 another instance?

Tobias Pankrath via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jan 2 08:13:47 PST 2015


On Friday, 2 January 2015 at 15:33:06 UTC, Suliman wrote:
> Thanks! I will try!
> D is my first compilable language, I wrote only some scripts 
> without OO before.
>
> So in my case your suggestion is best practice? Or there is any 
> more simple way to pass config and data to MySQL class?

I think it's fine to have a global config instance. Alternatively 
you can pass the config to both the seismoDownlead and 
MySqlWhatever classes.

// there ist enforce(cond, msg) for this in 
std.exception/std.conv, dunno.
if (!exists(confpath))  throw new Exception("ERROR: config.ini do 
not exists");
// it becomes
enforce(exists(confpath), "ERROR: config.ini does not exist");


More information about the Digitalmars-d-learn mailing list