weixin_36361030 2017-03-29 08:42 采纳率: 0%
浏览 1127

VS2010编译出错。。声明了啊,为什么还是出错

#include
#include
#include
using namespace std;
void getRandomNumbers(short,short&,short&);
void displayProblem(char,short&,short&);
short calCorrectAnswer(char,short,short);
void main()
{
short gradeLevel=0;
char operation=' ';
short num1=0,num2=0,correctAnswer=0,userAnswer=0;
cout<<"Enter grade level(1 or 2)";
cin>>gradeLevel;
cout<<"Enter operation(a or s)";
cin>>operation;
operation=toupper(operation);
getRandomNumbers(gradeLevel,num1,num2);
displayProblem(operation,num1,num2);
cin>>userAnswer;
correctAnswer=calCorrectAnswer(operation,num1,num2);
if(userAnswer==correctAnswer)
cout<<"You are right.";
else
cout<<"Sorry,the correct answeris "<<correctAnswer<<endl;
}
void getRandomNumber(short level,short&firstNum,short&secondNum)
{
srand((unsigned int)time(NULL));
if(level==1)
{
firstNum=1+rand()%(10-1+1);
secondNum=1+rand()%(10-1+1);
}
else
{
firstNum=1+rand()%(100-10+1);
secondNum=1+rand()%(100-1+1);
}
}
void diaplayProblem(char operation,short&firstNum,short&secondNum)
{
if(operation=='A')
cout<<firstNum<<"+"<<secondNum<<"=";
else
{
if(firstNum<secondNum)
{
short temp=0;
temp=firstNum;
firstNum=secondNum;
secondNum=temp;
}
}
}
short calCorrectionAnswer(char operation,short firstNum,short secondNum)
{
short answer=0;
if(operation=='A')
answer=firstNum+secondNum;
else
answer=firstNum-secondNum;
return answer;
}

1>------ 已启动生成: 项目: 初, 配置: Debug Win32 ------
1>RandomQ.obj : error LNK2019: 无法解析的外部符号 "short __cdecl calCorrectAnswer(char,short,short)" (?calCorrectAnswer@@YAFDFF@Z),该符号在函数 _main 中被引用
1>RandomQ.obj : error LNK2019: 无法解析的外部符号 "void __cdecl displayProblem(char,short &,short &)" (?displayProblem@@YAXDAAF0@Z),该符号在函数 _main 中被引用
1>RandomQ.obj : error LNK2019: 无法解析的外部符号 "void __cdecl getRandomNumbers(short,short &,short &)" (?getRandomNumbers@@YAXFAAF0@Z),该符号在函数 _main 中被引用
1>D:\VS2010\初\Debug\初.exe : fatal error LNK1120: 3 个无法解析的外部命令
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========

  • 写回答

3条回答 默认 最新

  • congliu0913 2017-03-29 08:51
    关注

    函数名写错了,你声明的分别是:
    void getRandomNumbers(short,short&,short&);
    void displayProblem(char,short&,short&);
    short calCorrectAnswer(char,short,short);
    但是函数名是:
    void getRandomNumber(short level,short&firstNum,short&secondNum)
    void diaplayProblem(char operation,short&firstNum,short&secondNum)
    short calCorrectionAnswer(char operation,short firstNum,short secondNum)
    可以使用notepad++辅助检查。

    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器