Talk About Network

Google


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++ > nested cl***** ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 43178 of 48417
Post > Topic >>

nested cl***** and derivation

by Christopher <cpisz@[EMAIL PROTECTED] > Feb 8, 2008 at 01:06 PM

This is going to be hard to explain. But I am looking for rules on
deriving nested cl***** in a scenario like the following:

class TaskLauncher
{
   // launches tasks which are child threads

   typedef std::vector<BaseTask *> Tasks
   Tasks m_tasks;

   // desire to be able to dynamic cast BaseTask pointer to a concrete
task type
   // and be able to retreive its stats when stats can be differant
types

};


class BaseTask
{
public:
   ...

private:
   class TaskStats
   {
      public:
         virtual const std::string GetStats() const;

         ...

      private:
         m_somestat;
   }m_stats;
};


class Task1 : public BaseTask
{
public:
   ...

private:
   class Task1Stats : public TaskStats
   {
      public:
         virtual const std::string GetStats() const;

      private:
         m_somestat;
         m_otherstat;
   }m_stats;
};


I don't really nest cl***** very often, but I figured it would be
convienant when users of the class want a particualr kind of stats
that they can qualify it with the task type. i.e Task1::m_stats or
BaseTask::m_stats and get the proper type of stats.

Do the names of member variables get overidden properly? i.e does
Task1::m_stats contain a m_otherstats member?

Is there a problem with Task1 being derived from BaseTask while its
nested Task1Stats is derived from TaskStats?

Did I get the syntax correct in my scenario example?
 




 3 Posts in Topic:
nested classes and derivation
Christopher <cpisz@[EM  2008-02-08 13:06:34 
Re: nested classes and derivation
"Victor Bazarov"  2008-02-08 16:57:04 
Re: nested classes and derivation
Grizlyk <grizlyk1@[EMA  2008-02-09 11:21:06 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Fri Nov 21 10:47:12 CST 2008.