緙栧啓涓涓垱寤烘椂,灝卞湪灞忓箷涓婃墦鍗癏ello,娑堝け鏃?灝辨墦鍗癎oodbye 鐨凜++紼嬪簭.
#include<iostream>
using聽namespace聽std;
class聽World{
聽聽聽聽聽聽聽聽public:
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽World(){//鍒涘緩鏃?/span>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽std::cout<<"Hello!\n";
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽~World(){//娑堝け鏃?/span>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽std::cout<<"Goodbye!\n";
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
};
//World聽theWorld;
int聽main(){
聽聽聽聽聽聽聽 //cout<<"Hello聽World\n";
聽聽聽聽聽聽聽聽World聽theWorld;
聽聽聽聽聽聽聽聽return聽0;
}
[root@portal聽ctest]#聽vi聽hello.c
[root@portal聽ctest]#聽g++聽hello.c聽-o聽hello
[root@portal聽ctest]#聽./hello
Hello!
Goodbye!
[root@portal聽ctest]#

]]>