国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

自學(xué)c++遇到的錯(cuò)誤,真是千奇百怪

2022-08-21 00:10 作者:祁連XU  | 我要投稿

報(bào)錯(cuò):

第一個(gè)

[Error]‘friend’ used outside of class
這個(gè)時(shí)候報(bào)錯(cuò)是因?yàn)樵陬愅舛x友元函數(shù)的時(shí)候,在函數(shù)頭部加了friend。

第二個(gè)

cannot have cv-qualifier//不能有CV限定

非成員函數(shù)不能有CV限定,友元函數(shù)不是類的成員函數(shù)聲明友元函數(shù)不能用const限定。

第三個(gè)報(bào)錯(cuò)比較多,但綜合看就一個(gè)最主要的

error: ‘time’ does not name a type

main.cpp: In function ‘int main()’:

main.cpp:8:13: error: expected ‘;’ before ‘a(chǎn)’

? ? 8 |? ? ? ? ?time a(3,35);

? ? ? |? ? ? ? ? ? ?^~

? ? ? |? ? ? ? ? ? ?;

main.cpp:9:13: error: expected ‘;’ before ‘b’

? ? 9 |? ? ? ? ?time b(2,48);

? ? ? |? ? ? ? ? ? ?^~

? ? ? |? ? ? ? ? ? ?;

main.cpp:10:13: error: expected ‘;’ before ‘t’

? ?10 |? ? ? ? ?time t;

? ? ? |? ? ? ? ? ? ?^~

? ? ? |? ? ? ? ? ? ?;

main.cpp:11:21: error: ‘a(chǎn)’ was not declared in this scope

? ?11 |? ? ? ? ?cout<<"a="<<a<<"\tb="<<b<<endl;

? ? ? |? ? ? ? ? ? ? ? ? ? ?^

main.cpp:11:32: error: ‘b’ was not declared in this scope

? ?11 |? ? ? ? ?cout<<"a="<<a<<"\tb="<<b<<endl;

? ? ? |? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^

main.cpp:12:9: error: ‘t’ was not declared in this scope; did you mean ‘tm’?

? ?12 |? ? ? ? ?t=a+b;

? ? ? |? ? ? ? ?^

? ? ? |? ? ? ? ?tm

socure.cpp:7:1: error: ‘time’ does not name a type

? ? 7 | time& operator+(time& a,const time& b)

? ? ? | ^~~~

socure.cpp:15:1: error: ‘time’ does not name a type

? ?15 | time& operator-(time&a,const time&b)

? ? ? | ^~~~

socure.cpp:23:1: error: ‘time’ does not name a type

? ?23 | time& operator*(time& a,const double d)

? ? ? | ^~~~

socure.cpp:36:40: error: ‘time’ does not name a type

? ?36 | ostream& operator<<(ostream & os,const time& a)

? ? ? |? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^~~~

socure.cpp: In function ‘std::ostream& operator<<(std::ostream&, const int&)’:

socure.cpp:38:28: error: request for member ‘hour’ in ‘a(chǎn)’, which is of non-class type ‘const int’

? ?38 |? ? ? ? ?os<<"hours is "<<a.hour<<",minutes is "<<a.minutes<<"."<<endl;

? ? ? |? ? ? ? ? ? ? ? ? ? ? ? ? ? ^~~~

socure.cpp:38:52: error: request for member ‘minutes’ in ‘a(chǎn)’, which is of non-class type ‘const int’

? ?38 |? ? ? ? ?os<<"hours is "<<a.hour<<",minutes is "<<a.minutes<<"."<<endl;

? ? ? |? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^~~~~~~

最終發(fā)現(xiàn)原來是類名用了time,個(gè)人感覺還是構(gòu)造函數(shù)和time()函數(shù)重復(fù)了,最終更換類名終于通過了

自學(xué)c++遇到的錯(cuò)誤,真是千奇百怪的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
友谊县| 敦化市| 平江县| 博罗县| 天镇县| 灵川县| 晋宁县| 临颍县| 赤壁市| 来宾市| 荔浦县| 瑞丽市| 韩城市| 海丰县| 湘西| 大洼县| 澳门| 秦皇岛市| 满洲里市| 江山市| 长海县| 库尔勒市| 武胜县| 边坝县| 平舆县| 二连浩特市| 永济市| 乳源| 江源县| 三江| 长岭县| 尼玛县| 汶上县| 淮南市| 宜春市| 南开区| 化德县| 武定县| 拜泉县| 资兴市| 陕西省|