求助
c++吧
全部回复
仅看楼主
level 9
include <iostream>
# include <string>
class Lovers
{
public:
Lovers(std::string theName);
void kiss(Lovers *lover);
void ask(Lovers *love, std::string something);
protected:
std::string name;
friend class other;
};
class BoyFirend : public Lovers
{
public:
BoyFirend(std::string theName);
};
class GirlFirend : public Lovers
{
public:
GirlFirend(std::string theName);
};
class other
{
public:
other(std::string theName);
void kiss(Lovers *lover);
};
Lovers::Lovers(std::string theName)
{
name = theName;
}
void Lovers::kiss(Lovers *lover)
{
std::cout << "亲亲我们家的" << lover->name << std::endl;
}
void Lovers::ask(Lovers *love, std::string something)
{
std::cout << "宝贝" << love->name << "帮我" << something << std::endl;
}
int main(void)
{
using namespace std;
BoyFirend boyFirend("A君");
cin.get();
return 0;
}
1>友元.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall BoyFirend::BoyFirend(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0BoyFirend@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z),该符号在函数 _main 中被引用
2016年10月01日 11点10分 1
level 13
函数没定义。
BoyFirend(std::string theName) :
Lovers(theName)
{}
2016年10月01日 12点10分 2
1