Hi Folks,
      I have written a code ... which is some simulation for COM (not a 
complete COM , just Query Interface .. that tooo only 1 method I kept) . But my 
app is crashing whenever I am trying to access that medthod.  I copy pasted the 
code . Please look into it . I marked those lines in red which are making app 
to crash.




#include<stdio.h>
#include<conio.h>
#include<windows.h>

struct IUnkn
{
    virtual HRESULT  QI(int IId,IUnkn **ptr) = 0;
    virtual void display()=0;
    
};
class MyOuterClass
{
public:
    int refCount;
    class MyInnerClass:public IUnkn
    {
    public:
        virtual HRESULT QI(int IId,IUnkn **ptr)
        {
            if(IId == 1)
            {
            IUnkn *pThis = (IUnkn *)((BYTE *)this+(int )(&(((class MyOuterClass 
*)0)->m_InnerObj)));
            *ptr = pThis;
            return 1;
            }
            *ptr = NULL;
            return 0;
        }
        virtual void display()
        {
            printf("\n I am in show method");
        }

    }m_InnerObj;
    friend class MyInnerClass;
};
void CreateObject(int IId,IUnkn **ptr)
{
    MyOuterClass obj;
    obj.m_InnerObj.QI(IId,ptr);
    (*ptr)->display();
    
}

void main()
{

    IUnkn *x;
    CreateObject(1,&x);
    x->display();
}



Thx,
--Gopi



      Add more friends to your messenger and enjoy! Go to 
http://messenger.yahoo.com/invite/

[Non-text portions of this message have been removed]

Reply via email to