Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User hako84's Avatar
    Join Date
    Jun 2009
    Posts
    46
    Hello

    I am new to Symbian C++, any help is greatly appreciated,

    I have defined a function as follows

    TDesC8* CsomeClass:: get _HBufC8_Ptr ()
    {
    Return i_hbufc8_ptr;
    }

    When i use :

    HBufC8* hbufcPtr = someObject-> get _HBufC8_Ptr();

    I get the error : invalid conversion from TDesC8* to HBufC8*

    Any ideas why ?

    Many thanks !

  2. #2
    Registered User vaibhavjain's Avatar
    Join Date
    Jan 2007
    Posts
    282
    Welcome to forum nokia Dibo.

    Since C++ is a statically typed language so the compiler cannot directly convert an object to its subtype. You have upcasted an HBufC8* to TDesC* , so downcasting will require a static or reinterpret cast (dynamic casting isnt available with sdk compilers). Please change to code below:

    HBufC8* hbufcPtr = STATIC_CAST(HBufC8*,someObject-> get _HBufC8_Ptr());

    or

    HBufC8* hbufcPtr = (HBufC8*)(someObject-> get _HBufC8_Ptr());


    Hope that helps,
    VJ

  3. #3
    Nokia Developer Champion hotcheese's Avatar
    Join Date
    Jul 2004
    Posts
    2,015
    There is no need to use casts with descriptors, in fact they should always be avoided.

    If you are returning a HBufC8* from a class and transferring ownership of that class then you should make the function return type a HBUfC8* also.

Similar Threads

  1. Cannot create sis package?
    By gomcoite in forum Themes/Carbide.ui
    Replies: 4
    Last Post: 2008-09-27, 17:54
  2. Error in packaging process :(
    By a-eqla3 in forum Themes/Carbide.ui
    Replies: 2
    Last Post: 2008-07-30, 22:03
  3. Error in packaging process :(
    By a-eqla3 in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2008-07-24, 20:33
  4. ERROR IN CREATING THEME
    By ssmantri in forum Themes/Carbide.ui
    Replies: 5
    Last Post: 2008-05-29, 20:58
  5. Need one HTTP client example
    By vinayakak in forum Symbian Networking & Messaging (Closed)
    Replies: 15
    Last Post: 2008-01-06, 06:44

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved