Hi guys I am a new IT guy.my task is to manipulate time and date.I use two separate classes for time and date. Now i need to integarate them, so which one is best Inheritance or containment

Recommended Answers

All 2 Replies

I would probably use containment. Don't use the name 'time' because that symbol is already used in time.h

class localtime
{

};

class date
{

};

class timedate
{
  localtime tm;
  date dt;
};
commented: Agreed, containment is much easier. :) +1

The term localtime is an existing symbol too. I wasn't 100% sure at first, the syntax highlighting in your code block actually tipped me off...

Probably better off using something a little more obfuscated, ?or even in a different language?. Perhaps use customTimeClass, leTemps (it's French, "the time") or something of that nature?

commented: Agree :) +31
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.