hello I have this .h file and I want to use the RGBImage class defined in it: It's called image.h. I can use it under a cygwin cygnus compiler.

Qt Code:
  1. #ifndef IMAGE_H
  2. #define IMAGE_H
  3.  
  4. #include <iostream.h>
  5.  
  6. template <class T> // an image of type T
  7. // use only simple types like int, unsigned char
  8. // double or float, etc.
  9. class Image {
  10.  
  11. private:
  12. T* pixel;
  13. int mHeight;
  14. int mWidth;
  15.  
  16. public:
  17. Image() { pixel = new T[1]; mHeight = mWidth = 0; }
  18. Image(const Image<T> & img );
  19. Image(int w, int h);
  20.  
  21. Image<T> & operator=(const Image<T> & img); // copy constructor
  22.  
  23. // OLD element access operator
  24. inline T & operator () (int x, int y) const {
  25. #ifdef IMAGE_RANGE_CHECK
  26. // cout << "Test range check..." << endl;
  27. if (y >= mHeight || x >= mWidth || y < 0 || x < 0) {
  28. cout << "Cannot access pixel (" << x << "," << y <<
  29. ") of Image[" << mWidth << " x " << mHeight << "]!" << endl;
  30. exit(1);
  31. }
  32. #endif
  33. return pixel[y * mWidth + x];
  34. }
  35.  
  36. // one-dimensional element access operator;
  37. inline T & operator [] (int i) const {
  38. #ifdef IMAGE_RANGE_CHECK
  39. if (i >= mWidth * mHeight || i < 0) {
  40. cout << "Cannot access pixel [" << i <<
  41. "] of Image[" << mWidth * mHeight << "]!" << endl;
  42. exit(1);
  43. }
  44. #endif
  45. return pixel[i];
  46. }
  47.  
  48. // destructor
  49. ~Image(){ delete [] pixel; }
  50.  
  51. void resize(int w, int h);
  52. void setAll( T x ); // set the values
  53.  
  54. inline int height() const { return mHeight; }
  55. inline int width() const { return mWidth; }
  56. T max();
  57. T min();
  58. };
  59.  
  60.  
  61. // --------------------------------------------------------------------
  62.  
  63. template <class T>
  64. Image<T>::Image( const Image<T> & img ) { // important for functions returning Image
  65. int h = img.height(), w = img.width(), i;
  66. pixel = new T[1];
  67. resize( w,h );
  68. for (i = 0; i < w*h; i++) pixel[i] = img[i];
  69. // for a faster alternative, replace previous line with the one below ;
  70. // and... you must #include <string.h>
  71. // memcpy( pixel, & img[0], sizeof(T) * w * h );
  72. }
  73.  
  74.  
  75. // set the image size only
  76. template <class T>
  77. Image<T>::Image( int w, int h ) {
  78. pixel = new T[1];
  79. resize( w,h );
  80. }
  81.  
  82.  
  83. // ---------------- Copy constructor -----------------------------------
  84. template <class T>
  85. Image<T> & Image<T>::operator=(const Image<T> & img) {
  86. int w,h,i;
  87. if ( this != &img ) { // don't copy to yourself
  88. resize( w = img.width(), h = img.height() );
  89. for (i = 0; i < w*h; i++) pixel[i] = img[i];
  90. // for a faster alternative, replace previous line with the one below ;
  91. // and... you must #include <string.h>
  92. // memcpy( pixel, & Img[0] , sizeof(T) * ht * wd );
  93. }
  94. return *this;
  95. }
  96.  
  97.  
  98. //----------- Allocates memory for an image, no initialization -----------
  99. template <class T>
  100. void Image<T>::resize(int w, int h) {
  101. int i;
  102. delete [] pixel;
  103.  
  104. if (w * h == 0) {
  105. cout << "CreateImage: invalid dimensions (" << w << " x " <<
  106. h << ")..." << endl;
  107. exit(1);
  108. }
  109.  
  110. pixel = new T[w*h];
  111. mWidth = w; mHeight = h;
  112. }
  113.  
  114.  
  115. // set the values of an image
  116. template <class T>
  117. void Image<T>::setAll( T x ) {
  118. int n = width() * height();
  119. for (int i = 0; i < n; i++) pixel[i] = x;
  120. }
  121.  
  122. // return the maximum value of the image
  123. template <class T>
  124. T Image<T>::max() {
  125. int i,imax,n = height()*width();
  126. for (i=imax=0; i < n; i++)
  127. if (pixel[i] > pixel[imax])
  128. imax = i;
  129. return pixel[imax];
  130. }
  131.  
  132. // return the minimum value of the image
  133. template <class T>
  134. T Image<T>::min() {
  135. int i,imin,n = height()*width();
  136. for (i=imin=0; i < n; i++)
  137. if (pixel[i] < pixel[imin])
  138. imin = i;
  139. return pixel[imin];
  140. }
  141.  
  142.  
  143.  
  144. #define RED(pixel) ((pixel) & 0xff)
  145. #define GREEN(pixel) (((pixel)>>8) & 0xff)
  146. #define BLUE(pixel) (((pixel)>>16) & 0xff)
  147. #define COLOR_RGB(r,g,b) (((b)<<16)+((g)<<8)+(r))
  148.  
  149.  
  150.  
  151. class RGBImage : public Image<int> {
  152.  
  153. public:
  154. RGBImage() { };
  155. ~RGBImage() { };
  156. inline void setPix( int x, int y, unsigned char r, unsigned char g, unsigned char b) {
  157. (*this)(x,y) = COLOR_RGB(r,g,b);
  158. }
  159. inline void setPix( int i, unsigned char r, unsigned char g, unsigned char b) {
  160. (*this)[i] = COLOR_RGB(r,g,b);
  161. }
  162. };
  163.  
  164.  
  165.  
  166.  
  167. #endif
To copy to clipboard, switch view to plain text mode 

Anybody can teach me specific steps to follow in order for me to use a fully-c++ .h file?