C++ empty String constructor

后端 未结 7 1889
误落风尘
误落风尘 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:21

    In C++, as in C, there is a rule that says that anything that looks like a declarartion will be treated as a declaration.

    string strA();
    

    looks like a function declaration, so it is treated as one. You need:

    string strA;
    

提交回复
热议问题