Sting str 和 String str = String() 区别??
class String
{
public:
String(){ cout < < "Constructor. " < < endl ; }
~String() { cout < < "Destroyer. " < < endl ;}
void Print(){ cout < < "Print sth. " < < endl ;}
} ;
int main()
{
String str1 ;// 语句1
String str2() ;// 语句2,这条语句是什么语句,好像一点不起作用?
}
// 但是编译器也没有说 语句2 错误!
---------
执行结果:
Constructor.
Destroyer.
Press any key to continue
[解决办法]
String str2() 被当成函数声明了.