×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    7

    operator overloading question

    hi all,

    I'm developing my own string class. In my class, I've overloaded = operator like below.

    String.h

    CString& operator=(const char* aStr);

    String.cpp

    CString& CString:perator=(const char* aStr)
    {
    if (iStrData) delete iStrData;

    iStrData = HBufC16::NewL(STRLEN(aStr));
    iStrData->Des().Append(*aStr);

    // Return myself
    return *this;
    }

    test.cpp

    CString* str = CString::NewL();
    char* s = "erdi";
    str = s;
    But in my test project, I receive compile error like below.

    illegal implicit conversion from 'char *' to CString*
    Any help will be appreciated.
    Regards.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,752

    Re: operator overloading question

    str is a pointer
    Code:
    *str=s;
    would be what you want.

Similar Threads

  1. illegal name overloading
    By vinp in forum Symbian
    Replies: 4
    Last Post: 2010-12-10, 00:24
  2. Overloading new opearator
    By Shilpa13 in forum Symbian
    Replies: 3
    Last Post: 2009-05-16, 09:18
  3. overloading delete operator
    By mihirg in forum Symbian
    Replies: 3
    Last Post: 2007-10-09, 09:02
  4. Replies: 1
    Last Post: 2006-02-17, 20:00
  5. question mark on operator logo
    By kelvynlaw in forum Symbian
    Replies: 0
    Last Post: 2005-09-06, 11:11

Posting Permissions

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