CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Threaded View

  1. #1
    Join Date
    Jun 2012
    Posts
    38

    Preventing execution of a function

    PHP Code:
    class MyClass{};
    namespace 
    BI{
        class 
    BusinessInterop
        
    {
        public:
            static 
    MyClassfunc(){printf("BusinessInterop");return new MyClass();}
        };
    }
    namespace 
    BS
    {
        
    using namespace BI;
        class 
    BusinessService:public BusinessInterop
        
    {
        public:
            
    virtual MyClassfunc(){return BusinessInterop::func();}
        };
    }
    namespace 
    XS
    {
        
    using namespace BS;
        class 
    xxxService:public BusinessService
        
    {
        public:    
            
    virtual MyClassfunc() {return func();}
            
    MyClassfunx()
            {
                return 
    func();
            }
        }; 
    }


    namespace 
    XT
    {
        
    using namespace XS;
        class 
    xxxServiceTest:public xxxService
        
    {
        public:
            
    virtual MyClassfunc() {printf("Business"); return new MyClass();}
            
    void Call()
            {
                
    funx();
            }
        };

    I would like to know how to prevent the program print out "Business", I'd like it to call the base class's static function. I have tried to changed MyClass* into void* but it still prints Business :grumpy:.
    My challenge is to output "BusinessInterop" without any changes made to the polymorphic structure as designed. Thank you.
    Last edited by terminalXXX; June 26th, 2013 at 10:52 AM.

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