|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 gby 于 2020-3-25 23:00 编辑
在Vc++6.0中运行,在工作空间双击 类Maid 下的setcolor(std::string color)会出现弹窗
Cannot find the definition (implementation) of this function.
代码能正常运行,但是这个错误是什么原因呢?
为方便查看setcolor(std::string color)后面特此用红色标注
以下是代码
/***************************************************************************************/
#include<iostream>
#include<string>
//#include <string.h>
class Maid
{
public:
void setcolor(std::string color);
void setsex(char *sex);
};
void Maid::setcolor(std::string color)
{
//此处用compare
int m=color.compare(0,5,"green",0,5);
int n=color.compare(0,4,"pink",0,4);
if(m==0)
{
system("color A");
std::cout<<m<<"\n";
std::cout<<n<<"\n";
}
else if(n==0)
{
system("color C");
std::cout<<m<<"\n";
std::cout<<n<<"\n";
}
else
{
std::cout<<"非法输入,你想干嘛!!!"<<"\n";
std::cout<<n;
}
}
void Maid::setsex(char *sex)
{
if(strcmp(sex,"no0")==0)
{
std::cout<<"好热呀,我要脱外套了";
}
else if(strcmp(sex,"no1")==0)
{
std::cout<<"诶呀,你干嘛脱我衬衫";
}
else
{
std::cout<<"错误输入"<<"\n";
}
}
void main()
{
std::string color;
char sex[10];
int high;
int weight;
Maid maid;
std::cout<<"请输入你想要的Maid颜色"<<"\n";
std::cout<<"//输入pink,则粉色(pink)"<<"\n"
<<"//输入green,则绿色(green)"<<"\n";
std::cin>>color;
maid.setcolor(color);//使全屏变色
std::cout<<"请输入你想要的Maid性感程度"<<"\n";
std::cout<<"//输入no0,则不穿外套"<<"\n"
<<"//输入no1,则不穿衬衫"<<"\n"
<<"//输入no2,则只穿丝袜"<<"\n"
<<"//输入no3,则不穿内衣"<<"\n";
std::cin>>sex;
maid.setsex(sex);
system("pause");
}
|
|