BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / cpp / #44231同步于 2010/9/25
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖

syntax error : missing ';' before 'string' 请高手指教 [求助

houmeng
2010/9/25镜像同步9 回复
#include<iostream.h> enum BREED{GOLDEN,CAIRN,DANDIE,SHETLAND,DOB,LAB}; class Mammal { public: Mammal():itsAge(2),itsWeight(5){} ~Mammal(){} int GetAge() const {return itsAge;} void SetAge(int age) {itsAge=age; } int GetWeight() const {return itsWeight;} void SetWeight(int weight) {itsWeight=weight;} void Speak() const {cout<<"mammal sound.\n";} void Sleep() const {cout"shhh,I am sleeping.\n";} protected: int itsAge; int itsWeight; }; class Dog: public Mammal { public: Dog():itsBreed(GOLDEN){} ~Dog(){} BREED GetBreed() const {return itsBreed;} void SetBreed(BREED breed){itsBreed=breed;} void WagTail() const {cout"tail....";} void BegForFood() const {cout<<"Begging for food..";} protected: BREED itsBreed; }; int main() { Dog Fidio; Fidio.Speak(); Fidio.WagTail(); cout<<"Fidio is "<<Fidio.GetAge()<<"years old"<<endl; return 0; } 编译错误说在Viod Sleep()前面发生这种错误:error C2143: syntax error : missing ';' before 'string'
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
zwp机器人#1 · 2010/9/25
#include <string.h> 适当的时候改为 #include <iostream> using namespace std;
ericyosho机器人#2 · 2010/9/25
你还是好好找本靠谱的书看吧。 C++里面,竟然还能 include xx.h 的么?
potatossss机器人#3 · 2010/9/25
void Sleep() const {cout"shhh,I am sleeping.\n";} 是說這行嗎?cout的操作符呢?<< ...
sdh2830机器人#4 · 2010/9/25
include "xxx.h"是可以的 如果这样写,下边就不能用namespace了; 这个主要问题还是cout,他可不是一个函数啊 cout“xxxxx”,没有运算符啊 【 在 ericyosho 的大作中提到: 】 : 你还是好好找本靠谱的书看吧。 : C++里面,竟然还能 include xx.h 的么? : -- : ...................
shenlei机器人#5 · 2010/9/25
re... 还有前面那个头文件也是个(潜在)问题... 【 在 potatossss (薯仔) 的大作中提到: 】 : void Sleep() const {cout"shhh,I am sleeping.\n";} : 是說這行嗎?cout的操作符呢?<< ...
slove机器人#6 · 2010/9/26
<< 少了这个~
rayallen机器人#7 · 2010/9/27
太霸气了这个/。。
JacKie575机器人#8 · 2010/9/29
C和C++已然混乱了。
babylike机器人#9 · 2010/9/29
void Speak() const {cout<<"mammal sound.\n";} void Sleep() const {cout"shhh,I am sleeping.\n";} //少了"<<"认真点,下边某行也这样