天天看點

Acclerated C++ 第0章

0-0:

#include<iostream>

int main(){

 std::cout << "hello,world" << std::endl;

 return 0;

}

0-1: 3+4; 是一個表達式語句,會執行3+4,結果7将放在一個臨時變量裡. 這個表達式沒什麼意義~~.

0-2:

#include<iostream>

int main(){

 std::cout << "This (*) is aquote, and this (//) is abackslash." << std::endl;

 return 0;

}

ps: /" = " , /' = ' , // = / ;

0-3:

#include<iostream>

int main(){

 std::cout << "********" << std::endl;

 std::cout << "/ta" <<std::endl;

 return 0;

}

/t 占8個字元寬

0-4:

#include <iostream>

using namespace std;

int main()

{

       cout<< "#include<iostream>" << endl;

       cout<< "int main()" << endl;

       cout<< "{" << endl;

       cout<< " cout <<\"hello, world!\" << endl;" << endl;

       cout<< " return 0;" <<endl;

       cout<< "}" << endl;

       return0;

}

0-5: 不正确 少了 {} 和 return .

0-6;VC6下能運作 抱一個警告.

0-7; 不正确 /* 注釋牽套了. 導緻一部注釋沒被包含.

0-8;正确 //後的是以内容都被注釋掉了

0-9; intmain(){}

0-10;

#include<iostream>

int

main

(

)

{

       cout

       <<

       "hello, world"

       <<

       endl;

       return

       0;

}