new (static_cast<void*>(this)) TestClass(passedInt);

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sendil kumar
    New Member
    • Sep 2007
    • 26

    new (static_cast<void*>(this)) TestClass(passedInt);

    Hi All,

    Can anybody tell me how the below statement executes.

    class TestClass
    {
    int m_testValue;
    public:
    TestClass(int testVal)
    {
    m_testValue = testVal;
    }

    ~TestClass() { }

    void callBack(int passedInt)
    {
    new (static_cast<vo id*>(this)) TestClass(passe dInt); //How this executes?
    //What is the meaning for it?
    }
    };

    Thanks,
    Sendil
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Well it doesn't compile for me (in VS 2005 Express with MS extensions off), what compiler are you compiling it in?

    Comment

    • Sendil kumar
      New Member
      • Sep 2007
      • 26

      #3
      I'm using Visual Studio 2005 Professional Edition Version 8.0.5

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        And does it compile without warning?

        Comment

        Working...