The Type conversion operator (type conversion operator) is a special class member function that defines the conversion of a class type value to another type value.
Change. The conversion operator is declared in the class definition body, followed by the target type of the conversion after the reserved word operator.
Class Cvimage
{
Public:
Cvimage ();
Explicit cvimage (unsigned int width, unsigned int height, unsigned short depth, unsigned short nchannels = 3);
Cvimage (cvimage& img);
~cvimage ();
void Releaseimage ();
int Resize (unsigned int width, unsigned int height, unsigned short depth, unsigned short nchannels = 3);
Operator iplimage* () {return m_image;};
Inline iplimage* GetImage () {return m_image;};
Private
Iplimage* M_image;
};
First of all, the type conversion constructor: explicit in C + + is used to decorate the constructor of a class, indicating that the constructor is displayed when the constructor that has the argument is called
Requires an explicit call:
Cvimage cImg = cvimage (640, 480, 8, 1);
Operator overloading operations:
Iplimage* operator () ()
{
return m_image;
}
C + + type conversion operations with operator overloading operator type () and type operator ()