Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Operator Overloading - C++

Tags:

c++

class sock  {
public:
    SOCKET m_hSock;
.....
//Other functons...contructors, destructors
.....
    operator SOCKET()
        { return m_hSock;}

}

In above coscket class code, what operator it is overloading?


1 Answers

This is known as the type cast operator. Operators of the form;

operator Type()

where Type is the desired type, are generally known as cast operators and can be used in casting operations, such as static_cast<Type>(obj)

like image 174
Niall Avatar answered Feb 19 '26 00:02

Niall



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!