CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Apr 2007
    Location
    Mars NASA Station
    Posts
    1,436

    Object of Class Template Instantiation

    Hello to all, I have a error logger class hierarchy which used utilize the template method pattern.

    I would like to create a class template that takes type of ClsErrorLogger class type as template argument which forward the request from class template to the ClsErrorLogger class.

    This program is running in a embedded system. I wonder is there any performance increase if i put the class template tplErrorLogger in a namespace and instantiate all the necessary object which is refer in later time.

    Code:
    namespace mySpace
    {
    template <class ClsErrorLogger>
    class tplErrorLogger
    {
    public:
      void logAll()
     {
       obj.log();
     }
    private:
      ClsErrorLogger obj;
    
    };
    
    // AFAIK, template instantiation is at compile time but i wonder 
    // whether the object tempalte instantiation is also at compile time.
    
    // Any performance increament if i do this
    tplErrorLogger<ClsErrorLogger> generalErrorLogger;
    tplErrorLogger<SessionMngtErrorLogger> sessionMngtErrorLogger;
    
    }
    
    class ClsErrorLogger
    {
    };
    
    class SessionMngtErrorLogger : ClsErrorLogger
    {
    };
    Please comment.

    Thanks.
    Attached Images Attached Images
    Thanks for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured