Typecasting for Class of Template Data type to unsigned char *

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KYAW KYAW OO
    New Member
    • Jan 2007
    • 30

    Typecasting for Class of Template Data type to unsigned char *

    Dear All,


    I am searching the way for Typecasting for Class of Template Data type to unsigned char *. Although I tried to browse in the internet and solve my best of knowledge, the issue is still there and here is my coding of conversion.


    a.h
    Code:
    class A
    {
    
    
    }
    types.h
    Code:
    typedef unsigned char  c_UInt8;

    main.cpp

    Code:
    HBITMAP hBitmap = (HBITMAP)LoadImage(NULL, fileName,IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
    	
    BITMAP m_sbmpBitmap;
    A<c_UInt8> greyImage(m_sbmpBitmap.bmWidth,m_sbmpBitmap.bmHeight);
    unsigned char * retImage = (unsigned char*) greyImage;
    I hope someone's advise to me since I am very tight in my development's schedule.

    Thanks in advance
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    If you mean you want a (unsigned) char * to the data contained by the class A which I assume is probably actually a dynamic array of some sort then the answer is you can not use a cast, you need to write a method on the class.

    You could write a casting operator but on the whole that is bad practice.

    Comment

    Working...