I’m relatively new to C++, and this declaration has me confused:
Service.h:
class ServiceHandle {
public:
ServiceHandle(SC_HANDLE h) : handle(h) {}
...
operator SC_HANDLE() const {return handle;}
protected:
SC_HANDLE handle;
};
I’ve created a ServiceHandle object through other means than the constructor listed here. I’d like to get the actual SC_HANDLE to pass to ChangeServiceConfig, how do I get at it? I’m assuming it’s something to do with the operator, but I can’t work out how to use it.
You just use the object of type
ServiceHandlein the expression tht expectsSC_HANDLE. The operator you’re talking about is the casting operator toSC_HANDLE. This operator is “used” automatically.