Thread: Returned Data query

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    36

    Returned Data query

    Hi guys

    I'm a c++ newbie and am having issues with returned data.

    In the documentation of the toolkit I'm using I'm provided with the following method:

    SbBool SoVolumeData::getVolumeData ( SbVec3s & dimension,
    void *& data, SoVolumeData:: DataType & type, int * numSignificantBits = NULL
    )

    Im trying to use the following code to get info pulled back but cant get this to work:

    Code:
    SoVolumeData *volData = new SoVolumeData();
    volData->fileName.setValue("./Data/WORSLEY-MAN.am");
    SbVec3s volDims = NULL;
    SoVolumeData *ptoData;
    SoVolumeData::DataType dtype ;
    int sigBits =0;
    volData->getVolumeData(volDims, ptoData, dtype, sigBits);
    Upon compiling I get the following error msg:

    error C2664: 'getVolumeData' : cannot convert parameter 2 from 'class SoVolumeData *' to 'void *& '
    A reference that is not to 'const' cannot be bound to a non-lvalue


    Any ideas what I need to alter in my code to resolve this...

    Thanks

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    That's interesting. You don't see void pointers used much in C++. Anyway, the problem is that the pointer-to-T to pointer-to-void conversion results in an rvalue. You can't have a reference to an rvalue, so the function call is ill-formed. It also means that an explicit cast is also not going to work for the same reason.

    The only way I can think of at the moment to work around this particular problem without changing the parameter list of the function in question is to use a void pointer first, then point ptoData to it after the function call:
    Code:
    void *vptoData;
    volData->getVolumeData(volDims, vptoData, dtype, sigBits);
    SoVolumeData *ptoData = static_cast<SoVolumeData*>(vptoData);
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 10:13 AM
  2. Binary Tree, couple questions
    By scoobasean in forum C Programming
    Replies: 3
    Last Post: 03-12-2005, 09:09 PM
  3. binary tree of processes
    By gregulator in forum C Programming
    Replies: 1
    Last Post: 02-28-2005, 12:59 AM
  4. Dynamic data members?
    By confusalot in forum C++ Programming
    Replies: 4
    Last Post: 02-27-2005, 11:15 AM
  5. All u wanted to know about data types&more
    By SAMSAM in forum Windows Programming
    Replies: 6
    Last Post: 03-11-2003, 03:22 PM