error LNK2019: 无法解析的外部符号”哪位高手碰到过,一个小程序,帮忙看看
error LNK2019: 无法解析的外部符号”谁碰到过,一个小程序,帮忙看看
#include <iostream>
#include <cstdlib>
using namespace std;
class throttle
{
public:
void shut_off();
void shift(int amount);
double flow() const;
bool is_on()const;
private:
int position;
};
int main( )
{
throttle sample;
int user_input;
cout<<"I have a throttle with 6 positions."<<endl;
cout<<"Where would you like to set the throttle?"<<endl;
cout<<"Please type a number from 0 to 6:";
cin>>user_input;
sample.shut_off();
sample.shift(user_input);
while(sample.is_on())
{
cout<<"The flow is now "<<sample.flow()<<endl;
sample.shift(-1);
}
cout<<"The flow is now off"<<endl;
return EXIT_SUCCESS;
}
1>main.obj : error LNK2019: 无法解析的外部符号 "public: double __thiscall throttle::flow(void)const " (?flow@throttle@@QBENXZ),该符号在函数 _main 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 "public: bool __thiscall throttle::is_on(void)const " (?is_on@throttle@@QBE_NXZ),该符号在函数 _main 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 "public: void __thiscall throttle::shift(int)" (?shift@throttle@@QAEXH@Z),该符号在函数 _main 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 "public: void __thiscall throttle::shut_off(void)" (?shut_off@throttle@@QAEXXZ),该符号在函数 _main 中被引用
1>D:\vs2010test\ceshi\Debug\ceshi.exe : fatal error LNK1120: 4 个无法解析的外部命令
1>
1>生成失败。
这个什么情况?有什么解决方法么?查了很多资料,可能缺少库文件,如果是的话,缺少那些库文件呢?
------解决思路----------------------
这是你自己写的类,自己实现函数啊。或者用人家的库,但你这不是用人家的库额。
------解决思路----------------------
throttle类里面的函数需要有实现
------解决思路----------------------
类的函数没实现
#include <iostream>
#include <cstdlib>
using namespace std;
class throttle
{
public:
void shut_off();
void shift(int amount);
double flow() const;
bool is_on()const;
private:
int position;
};
int main( )
{
throttle sample;
int user_input;
cout<<"I have a throttle with 6 positions."<<endl;
cout<<"Where would you like to set the throttle?"<<endl;
cout<<"Please type a number from 0 to 6:";
cin>>user_input;
sample.shut_off();
sample.shift(user_input);
while(sample.is_on())
{
cout<<"The flow is now "<<sample.flow()<<endl;
sample.shift(-1);
}
cout<<"The flow is now off"<<endl;
return EXIT_SUCCESS;
}
1>main.obj : error LNK2019: 无法解析的外部符号 "public: double __thiscall throttle::flow(void)const " (?flow@throttle@@QBENXZ),该符号在函数 _main 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 "public: bool __thiscall throttle::is_on(void)const " (?is_on@throttle@@QBE_NXZ),该符号在函数 _main 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 "public: void __thiscall throttle::shift(int)" (?shift@throttle@@QAEXH@Z),该符号在函数 _main 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 "public: void __thiscall throttle::shut_off(void)" (?shut_off@throttle@@QAEXXZ),该符号在函数 _main 中被引用
1>D:\vs2010test\ceshi\Debug\ceshi.exe : fatal error LNK1120: 4 个无法解析的外部命令
1>
1>生成失败。
这个什么情况?有什么解决方法么?查了很多资料,可能缺少库文件,如果是的话,缺少那些库文件呢?
------解决思路----------------------
class throttle
{
public:
void shut_off();
void shift(int amount);
double flow() const;
bool is_on()const;
这是你自己写的类,自己实现函数啊。或者用人家的库,但你这不是用人家的库额。
------解决思路----------------------
throttle类里面的函数需要有实现
------解决思路----------------------
类的函数没实现