※ 引述《quota@kkcity.com.tw (我要出清)》之銘言:
> 請教一下,我在vc的書籍上看到
> #include "stdafx.h"
> #include <stdio.h>
> using namespace std;
你的書很舊了,
一般會叫你寫成 #include <cstdio>,
狠一點的純 C++ compiler 甚至不放 stdio.h 這個檔,
編譯的時候跟你說找不到。
> 我要問的問題很簡單..但是因為書本上沒有寫
> 我百思不得其解
> 只好冒昧上來問
> 1.當我做include時,何時要加上"" 何時要用<>呢?
> 如果是cstring.h 那該用哪一個呢?
這個有人回了,就不再重複他回的部分。
不過 <> 一般只用來抓 compiler 預設的搜尋路徑,
有些 compiler 只要指定 include path 的話 <> 和 "" 都抓得到,
以一般的慣例來說如果是自己寫的就用 ""。
> 2.如果我在編譯時,不論用"iostream.h"或<iostream.h>
> 都會出現找不到這個檔案的訊息,那我該如何偵錯呢?
請改用 <iostream>,
現在新做出來的 C++ 開發環境幾乎不會向下相容,
也就是說連 iostream.h 檔都不提供。
> 3.請問何時使用「using namespace std;」?
> 因為我看到有的專案有,有的專案沒有。
很舊的就會沒有,
而且通常沒辦法通過新的 C++ compiler 編譯,
你講的這個書上就有說了,
查看看 namespace 的那一章。
--
Name: Tseng, Ling-hua E-mail Address: uranus@it.muds.net
School: National Chung Cheng University
Department: Computer Science and Information Engineering
Researching: Porting GCC and Implementing VLIW instruction scheduler in GCC
Homepage: https://it.muds.net/~uranus
--
╔═══╗ ┼────────────────────────╮
║狂狷 ║ │* Origin:[ 狂 狷 年 少 ] whshs.cs.nccu.edu.tw ╰─╮
║ 年少║ ┼╮ < IP:140.119.164.16 > ╰─╮
╚╦═╦╝ ╰ * From:218-171-147-15.dynamic.hinet.net
─╨─╨─ KGBBS ─ ◎ 遨翔"BBS"的狂狷不馴;屬於年少的輕狂色彩 ◎