How cast C++ class to intrinsic type

前端 未结 2 380
清歌不尽
清歌不尽 2021-01-18 13:01

Basic C++ class question:

I have simple code currently that looks like something like this:

typedef int sType;
int array[100];

int test(sType s)
{
          


        
2条回答
  •  情歌与酒
    2021-01-18 13:39

    class sType
    {
    public:
        operator int() const { return val; }
    
    private:
        int val;
    };
    

提交回复
热议问题