C++ empty String constructor

后端 未结 7 1920
误落风尘
误落风尘 2021-02-13 02:56

I am a C++ beginner, so sorry if the question is too basic.

I have tried to collect the string constrcturs and try all them out (to remember them).

strin         


        
7条回答
  •  名媛妹妹
    2021-02-13 03:14

    tkopec is right on why it doesn't work. To answer your second question, here's how you check the type:

    template void Error_() {
       TEST* MakeError = 1;
    }
    

    By calling Error_(StrA); you will get a compile error, and your compiler will probably tell you that it happened in Error_< std::basic_string > (*)(void)>(std::basic_string > (*)(void)) Now, std::basic_string > is just std::string, so this really means Error_< std::string (*)(void)> (std::string (*)(void)). The part between '<>' is repeated between '()', and that's the sype of strA. In this case, std::string (*)(void).

提交回复
热议问题