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

Thread: how to do?

Threaded View

  1. #1
    Join Date
    Jan 2005
    Posts
    54

    Question how to do?

    Code:
    class myClass
    {
    public:
         myClass();
         myClass(myClass&);
         myClass& operator = (myClass&);
         mySubClass * pSubClass
         const char* getName();
         void  setName(const char*);
         int   getValue();
         void  setValue(int);
    private:
         char* szName;
         int nValue;
    }
    myClass::myClass()
    { 
         szName=new char[16];
         strcpy(szName,"unknown");
         nValue=-1;
         pSubClass=new mySubClass;
         return; 
    }
    myClass::myClass(myClass& CValue)
    {
         szName=new char[16];
         strcpy(szName,CValue.getName());
         nValue=CValue.getValue();
         pSubClass=new mySubClass;
         pSubClass=CValue.pSubClass;
         return; 
    }
    myClass::myClass::operator=(myClass& CValue)
    {
         szName=new char[16];
         strcpy(szName,CValue.getName());
         nValue=CValue.getValue();
         pSubClass=new mySubClass;
         pSubClass=CValue.pSubClass;
         return *this; 
    }
    
    myClass::~myClass()
    { 
         delete [] szName;
         delete pSubClass;
         return; 
    }
    class mySubClass
    {
    public:
         mySubClass();
         mySubClass(mySubClass&);
         mySubClass& operator = (mySubClass&);
         const char* getName();
         void  setName(const char*);
         int   getValue();
         void  setValue(int);
    private:
         char* szName;
         int nValue;
    }
    mySubClass::mySubClass()
    { 
         szName=new char[16];
         strcpy(szName,"unknown");
         nValue=-1;
         return; 
    }
    mySubClass::mySubClass(mySubClass& CValue)
    {
         szName=new char[16];
         strcpy(szName,CValue.getName());
         nValue=CValue.getValue();
         return; 
    }
    mySubClass::mySubClass::operator=(mySubClass& CValue)
    {
         szName=new char[16];
         strcpy(szName,CValue.getName());
         nValue=CValue.getValue();
         return *this; 
    }
    mySubClass::~mySubClass()
    { 
         delete [] szName;
         return; 
    }
    other member function.
    void myFunction(myClass&CValue)//fill CValue
    {
    }
    int main(int argc, char* argv[])
    {
    	class myClass CMyClass;
                    myFunction(CMyClass);
    	return 0;
    }
    Why I get Debug error: DAMAGE after normal block(#66) at 0x00894120? What is wrong with it? How to fix it? Thanks
    Last edited by Andreas Masur; January 20th, 2005 at 05:03 PM. Reason: Added code tags...

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