开发者

Create C++ Class with "Default/Main" Value (ie 'string')

开发者 https://www.devze.com 2023-02-08 11:27 出处:网络
so i wondering on how you 开发者_如何学JAVAcreate a class in c++ where the object itself has a main value like how \'string\' works

so i wondering on how you 开发者_如何学JAVAcreate a class in c++ where the object itself has a main value like how 'string' works

for example:

MySocket m = SOCKET kSocket;
m.Connect(...);
SOCKET aSocket = m;

where m has a default type of SOCKET but has other variables and functions


It is late.. so I am going to make a big leap here.

I think you are looking for auto type converters. There isn't a default type. What you are looking for is a way to automatically type convert a m into a SOCKET.

look up using something like

    class MySocket
    {
        public:
          operator SOCKET()
          {
                SOCKET socket;
                socket.handle = _handle;
                return socket;
          }
    };
0

精彩评论

暂无评论...
验证码 换一张
取 消