标题:求高手解决C++中的 cin cout 为什么重视报错
只看楼主
阳光猪
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2014-3-5
结帖率:100%
已结贴  问题点数:20 回复次数:10 
求高手解决C++中的 cin cout 为什么重视报错
#include "VEmotion.h"
#include<iostream>
using namespace std;
void main()
{
 int index=0;
 AMsg pMsg;
 AMsg UName;
AMsg questions[10]={"你喜欢跳舞吗玩吗?(y/n)","我想和你交朋友,你愿意吗?(y/n)","亲爱的,你爱我吗?(y/n)","嫁给我吧(y/n)","我们离婚吧(y/n)"}
};
cout<<"输入姓名:";
cin>>UName;
cout<<"今天遇到一个熟悉的陌生人,他对你很感兴趣……"<<endl;
VEmotion sample;
cout<<"嗨!"<<UName<<",";
 while(1)
 {
  cout<<questions[index];
  cin>>pMsg;
  sample.event(pMsg);
  index=sample.getRelation()-1;
  if(sample.Rejection()==MAX_BEAR_TIME)
  {
    cout<<endl<<"***你很讨厌我吗???****"<<endl;
  }
  if(sample.Relation()==BYEBYE)
  {
    cout<<endl<<"***对不起,不要流泪****"<<endl;
  }
 }
}

--------------------Configuration: zhu3_5 - Win32 Debug--------------------
Compiling...
main.cpp
C:\Documents and Settings\zhu3_5\main.cpp(10) : error C2143: syntax error : missing ';' before '}'
C:\Documents and Settings\zhu3_5\main.cpp(11) : error C2143: syntax error : missing ';' before '<<'
C:\Documents and Settings\zhu3_5\main.cpp(11) : error C2501: 'cout' : missing storage-class or type specifiers
C:\Documents and Settings\zhu3_5\main.cpp(11) : error C2371: 'cout' : redefinition; different basic types
        c:\program files\microsoft visual studio\vc98\include\ostream.h(139) : see declaration of 'cout'
C:\Documents and Settings\zhu3_5\main.cpp(11) : error C2143: syntax error : missing ';' before '<<'
C:\Documents and Settings\zhu3_5\main.cpp(12) : error C2143: syntax error : missing ';' before '>>'
C:\Documents and Settings\zhu3_5\main.cpp(12) : error C2501: 'cin' : missing storage-class or type specifiers
C:\Documents and Settings\zhu3_5\main.cpp(12) : error C2371: 'cin' : redefinition; different basic types
        c:\program files\microsoft visual studio\vc98\include\istream.h(173) : see declaration of 'cin'
C:\Documents and Settings\zhu3_5\main.cpp(12) : error C2143: syntax error : missing ';' before '>>'
C:\Documents and Settings\zhu3_5\main.cpp(13) : error C2143: syntax error : missing ';' before '<<'
C:\Documents and Settings\zhu3_5\main.cpp(13) : error C2501: 'cout' : missing storage-class or type specifiers
C:\Documents and Settings\zhu3_5\main.cpp(13) : error C2371: 'cout' : redefinition; different basic types
        c:\program files\microsoft visual studio\vc98\include\ostream.h(139) : see declaration of 'cout'
C:\Documents and Settings\zhu3_5\main.cpp(13) : error C2143: syntax error : missing ';' before '<<'
C:\Documents and Settings\zhu3_5\main.cpp(15) : error C2143: syntax error : missing ';' before '<<'
C:\Documents and Settings\zhu3_5\main.cpp(15) : error C2501: 'cout' : missing storage-class or type specifiers
C:\Documents and Settings\zhu3_5\main.cpp(15) : error C2371: 'cout' : redefinition; different basic types
        c:\program files\microsoft visual studio\vc98\include\ostream.h(139) : see declaration of 'cout'
C:\Documents and Settings\zhu3_5\main.cpp(15) : error C2143: syntax error : missing ';' before '<<'
C:\Documents and Settings\zhu3_5\main.cpp(16) : error C2143: syntax error : missing ';' before 'while'
C:\Documents and Settings\zhu3_5\main.cpp(17) : error C2143: syntax error : missing ';' before '{'
C:\Documents and Settings\zhu3_5\main.cpp(17) : error C2447: missing function header (old-style formal list?)
C:\Documents and Settings\zhu3_5\main.cpp(31) : error C2143: syntax error : missing ';' before '}'
C:\Documents and Settings\zhu3_5\main.cpp(31) : error C2143: syntax error : missing ';' before '}'
C:\Documents and Settings\zhu3_5\main.cpp(31) : error C2143: syntax error : missing ';' before '}'
搜索更多相关主题的帖子: include 陌生人 交朋友 我们离婚吧 爱我 
2014-03-05 22:29
wp231957
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:神界
等 级:版主
威 望:422
帖 子:13681
专家分:53296
注 册:2012-10-18
得分:5 
你的花括号貌似都不配对

DO IT YOURSELF !
2014-03-05 22:33
梦落尘埃
Rank: 2
来 自:wust
等 级:论坛游民
帖 子:7
专家分:25
注 册:2014-2-18
得分:5 
第十行分号前的花括号多了。。。

带着梦想到处游,无所谓
2014-03-05 22:52
peach5460
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:武汉
等 级:贵宾
威 望:30
帖 子:2780
专家分:6060
注 册:2008-1-28
得分:5 
以下是引用wp231957在2014-3-5 22:33:08的发言:

你的花括号貌似都不配对

+1

我总觉得授人以鱼不如授人以渔...
可是总有些SB叫嚣着:要么给代码给答案,要么滚蛋...
虽然我知道不要跟SB一般见识,但是我真的没修炼到宠辱不惊...
2014-03-06 08:22
阳光猪
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2014-3-5
得分:0 
谢谢大家,粘贴上去才看到数组的地方多了一个花括号 可是cin cout的问题还在呀

#include "VEmotion.h"
#include<iostream>
using namespace std;
void main()
{
 int index=0;
 AMsg pMsg;
 AMsg UName;
AMsg questions[10]={"你喜欢跳舞吗玩吗?(y/n)","我想和你交朋友,你愿意吗?(y/n)","亲爱的,你爱我吗?(y/n)","嫁给我吧(y/n)","我们离婚吧(y/n)"};
cout<<"输入姓名:";
cin>>UName;
cout<<"今天遇到一个熟悉的陌生人,他对你很感兴趣……"<<endl;
VEmotion sample;
cout<<"嗨!"<<UName<<",";
 while(1)
 {
  cout<<questions[index];
  cin>>pMsg;
  sample.event(pMsg);
  index=sample.getRelation()-1;
  if(sample.getRejection()==MAX_BEAR_TIME)
  {
    cout<<endl<<"***你很讨厌我吗???****"<<endl;
  }
  if(sample.getRelation()==BYEBYE)
  {
    cout<<endl<<"***对不起,不要流泪****"<<endl;
  }
 }
}
--------------------Configuration: zhu3_5 - Win32 Debug--------------------
Compiling...
main.cpp
C:\Documents and Settings\zhu3_5\main.cpp(10) : error C2872: 'cout' : ambiguous symbol
C:\Documents and Settings\zhu3_5\main.cpp(11) : error C2872: 'cin' : ambiguous symbol
C:\Documents and Settings\zhu3_5\main.cpp(12) : error C2872: 'cout' : ambiguous symbol
C:\Documents and Settings\zhu3_5\main.cpp(14) : error C2872: 'cout' : ambiguous symbol
C:\Documents and Settings\zhu3_5\main.cpp(17) : error C2872: 'cout' : ambiguous symbol
C:\Documents and Settings\zhu3_5\main.cpp(18) : error C2872: 'cin' : ambiguous symbol
C:\Documents and Settings\zhu3_5\main.cpp(23) : error C2872: 'cout' : ambiguous symbol
C:\Documents and Settings\zhu3_5\main.cpp(27) : error C2872: 'cout' : ambiguous symbol
Error executing cl.exe.

main.obj - 8 error(s), 0 warning(s)
2014-03-06 16:38
阳光猪
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2014-3-5
得分:0 
回复 2楼 wp231957
谢谢
2014-03-06 16:39
阳光猪
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2014-3-5
得分:0 
回复 3楼 梦落尘埃
非常感谢
2014-03-06 16:40
阳光猪
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2014-3-5
得分:0 
回复 4楼 peach5460
感谢
2014-03-06 16:40
wp231957
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:神界
等 级:版主
威 望:422
帖 子:13681
专家分:53296
注 册:2012-10-18
得分:5 
没有第一个 那个 神马点H文件  无法测试

DO IT YOURSELF !
2014-03-06 17:13
阳光猪
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2014-3-5
得分:0 
#if !defined _VEmotion
#define _VEmotion
#endif
#include <iostream.h>
#include<string.h>
#define MSG_LEN_MAX 100
#define MAX_BEAR_TIME 3
typedef char AMsg[MSG_LEN_MAX];
enum AState{
   STRANGER=1,
   KNOWN=2,
   FRIEND=3,
   COUPLE=5,
   BYEBYE=0,
};

class VEmotion  
{
public:
    VEmotion();
    virtual ~VEmotion();
    int event(AMsg pMsg);
    AState getRelation()
    {
      return Relation;
    }
    int getRejection()
    {
      return Rejection;
    }
private:
     AState  Relation;
     int  Rejection;


};
2014-03-06 17:22



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-428074-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.104732 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved