C++ Data Types from Templates

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

    C++ Data Types from Templates

    Dear All,


    I am trying to write a wrapper DLL from the other SDK's template library to use applcaition in C++ and .NET.

    For example

    Class A;
    typedef unsigned char c_UInt8;
    A<c_UInt8> bufImage;

    buf = bufImage; // here I am looking for the suitable and equivalnet data type of bufImage



    Please advise me if you had any experiences on it and I am looking forward to hearing from you.


    Thanks and best regards
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    The data type of bufInage is A<c_UInt8>. Whatever type buf is will require an operator= on class A.

    Maybe you could explain further

    BTW: a c_ does not make a variable a char or unsigned char. This sort of thing started back in the 1970's with assembly programming and has been dying a slow death. Mpst development tools today let you float the cursor over the variable and the type is displayed. Naming conventions are all failues since they rely on perfection by humans since the compiler cannot enforce the convention.

    Comment

    • KYAW KYAW OO
      New Member
      • Jan 2007
      • 30

      #3
      Data Type Conversion

      Dear All,



      I tried to type cast the image memory of unsigned char * to unsigned long * as in here.

      unsigned char *colorImage = new unsigned char[colorBmWidth * colorBmHeight * 3];
      // Convert from unsigned char * to unsigned long *
      unsigned long *lColorContent = (unsigned long*) colorImage;

      My original data is 24 bits bitmap image and still couldn't managed to solve it even I searched the solutions in the internet.
      Here is my debugging data
      colorImage -> BM6̓
      colorContent -> 3442888002

      Actually, the colorContent must be colorContent -> BM6̓ but I don't know why there is errors there.

      I am looking forward to hearing form you soon.


      Thanks and best regards

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Probably there no errors. The default for disoplaying an int or long is to show the numbers. For a char*, it is assumed to be a string so it shows the characters until a \0.

        BTW: This looks like C and not C++.

        Comment

        Working...