Redefinition of variables.

This is a discussion on Redefinition of variables. within the C++ Programming forums, part of the General Programming Boards category; Hello This might be simple to answer, but please bear with me. My image processing program needs to use various ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    10

    Redefinition of variables.

    Hello

    This might be simple to answer, but please bear with me. My image processing program needs to use various types ie short, long, float. I get a pointer (*pMod) to a pixel which is used to modify the pixel values.


    Code:
    hr = SafeArrayPtrOfIndex(pData, ij, (void **)&pMod);
    if (FAILED(hr)) AfxMessageBox("nope");
    					
    (*pMod) = dVal;
    However the pointer clearly needs to be of the same type as the Safearray, therefore I want to CHANGE THE VARIABLE TYPE, KEEPING THE POINTER NAME CONSTANT for use with different image types. I've tried using unions, but unless mistaken I cannot change the type without using a switch. IS there any other way?

    Thanks for your attention.

    Will

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    you need the switch statement to find out what data type is contained in the VARIANT object, assuming the SAFEARRAY is an array of type VT_VARIANT. If it can contain a variety of data types, the the switch is necessary -- if you know it will always be one data type then the switch is probably not necessary

    If all you want to do is get an element out of the array, you can use other functions, such as SafeArrayGetElenment()

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  2. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  3. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 02:49 PM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 07:13 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21