亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

C不是C+的子集在哪里?

C不是C+的子集在哪里?

C++ C
汪汪一只貓 2019-07-10 15:05:28
C不是C+的子集在哪里?我在很多書中讀到,C是C+的一個子集。有些書說C是C+的子集,除了那些小細節.在某些情況下,代碼將在C中編譯,而不是C+?
查看完整描述

3 回答

?
拉丁的傳說

TA貢獻1789條經驗 獲得超8個贊

如果你比較C89帶著C++下面是幾件事


C+中沒有暫定定義

int n;

int n; // ill-formed: n already defined

int[]和int[N]不兼容(C+中沒有兼容類型)

int a[1];

int (*ap)[] = &a; // ill-formed: a does not have type int[]

無K&R函數定義樣式

int b(a) int a; { } // ill-formed: grammar error

嵌套結構在C+中具有類范圍。

struct A { struct B { int a; } b; int c; };

struct B b; // ill-formed: b has incomplete type (*not* A::B)

沒有默認的int

auto a; // ill-formed: type-specifier missing

C99增加了很多其他案例


參數數組尺寸中的聲明說明符沒有特殊處理

// ill-formed: invalid syntax

void f(int p[static 100]) { }

無變長陣列

// ill-formed: n is not a constant expression

int n = 1;

int an[n];

沒有靈活的數組成員

// ill-formed: fam has incomplete type

struct A { int a; int fam[]; }; 

沒有用于幫助混疊分析的限制限定符

// ill-formed: two names for one parameter?

void copy(int *restrict src, int *restrict dst);


查看完整回答
反對 回復 2019-07-10
?
慕標琳琳

TA貢獻1830條經驗 獲得超9個贊

在C中,sizeof('a')等于sizeof(int).

在C+中,sizeof('a')等于sizeof(char).


查看完整回答
反對 回復 2019-07-10
?
明月笑刀無情

TA貢獻1828條經驗 獲得超4個贊

C+也有新的關鍵字。以下是有效的C代碼,但不能在C+下編譯:


int class = 1;

int private = 2;

int public = 3;

int virtual = 4;


查看完整回答
反對 回復 2019-07-10
  • 3 回答
  • 0 關注
  • 607 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號