为什么他的语法正确的程序不能在带有llvm编译器的Xcode IDE上编译?
Why won't his syntactically correct program compile on the Xcode IDE with llvm compiler?
github存储库:https://github.com/d-parkinson/C-practice-file.git
创建于2016年4月4日,作者Darren Parkinson。这是一款由两个角色组成的双人模拟格斗游戏:恶棍与英雄每个字符分别具有四个功能:名称(字符串)、运行状况(整数)、踢球(整数)和打孔(整数)
#include <iostream>
#include <string>
包含有关字符特征的详细信息的超类
class Character{
public:
std::string name;
static int health;
int kick;
int punch;
Character(std::string name, int health, int kick, int punch){
this -> health = health;
this -> name = name;
this -> kick = kick;
this -> punch = punch;
}
~Character(){}
};
显示英雄特征的子类
class Hero : public Character{
public:
Hero(std::string name, int health, int kick, int punch) : Character(name, health, kick, punch){
std::cout << name << ": Joker giving trouble again" << std::endl;
}
~Hero(){}
};
显示绒毛特征的子类
class Villian : public Character{
public:
Villian(std::string name, int health, int kick, int punch) : Character(name, health, kick, punch){
std::cout << name << ": Hey there hehehe" << std::endl;
}
~Villian(){}
};
说明反派和英雄类之间动作的功能
void VillianPunch(Hero *hero, Villian *villian){
hero -> health -= villian -> punch;
std::cout << villian -> name << ": take this(punch)" << std::endl;
}
void VillianKick(Hero *hero, Villian *villian){
hero -> health -= villian -> kick;
std::cout << villian -> name << ": take this(kick)" << std::endl;
}
void HeroPunch(Hero *hero, Villian *villian){
villian -> health -= hero -> punch;
std::cout << hero -> name << ": take this(punch)" << std::endl;
}
void HeroKick(Hero *hero, Villian *villian){
villian -> health -= hero -> kick;
std::cout << hero -> name << ": take this(kick)" << std::endl;
}
主要功能
int main(void){
Hero *batman;
Villian *joker;
joker = new Villian("Joker",1000,90,63);
batman = new Hero("Batman",1100,93,60);
std::cout << "Fight!!!" << std::endl;
做功能模拟维廉和英雄之间的战斗
do{
HeroPunch(batman, joker);
VillianPunch(batman, joker);
VillianKick(batman, joker);
HeroKick(batman, joker);
if(batman -> health <= 0)
std::cout << joker -> name << ": You won't catch me today hehehe" << std::endl;
else if(joker -> health <= 0)
std::cout << batman -> name << ": How many times do I have to defeat you" << std::endl;
}while((batman -> health > 0) & (joker -> health > 0));
delete joker;
delete batman;
return 0;
}
我是一名新的c++程序员,正在练习git和堆栈溢出
以下错误消息:"字符::健康",引用自:
VillianPunch(英雄*,Villian*)在游戏模拟。o
游戏模拟中的VillianKick(英雄*,Villian*)。o
HeroPunch(英雄*,维廉*)在游戏模拟。o
HeroKick(英雄*,维廉*)在游戏模拟。o
_主要在游戏模拟。o
字符::字符(std::__1::basic_string,std::___1::allocater>,int,int,int)。old:
找不到体系结构x86_64 的符号
clang:错误:链接器命令失败,退出代码为1(使用-v参见调用)
代码编译了;错误消息来自链接器。(至于链接器为什么找不到它抱怨的符号,这可能是代码、游戏模拟库和标准库之间的交互中的某个地方,我不会猜测。)
相关文章:
- C/C++编译器通常会删除重复的库吗
- 模板-模板参数推导:三个不同的编译器三种不同的行为
- Win32编译器选项和内存分配
- macOS 是内置在 clang 编译器中还是内置于 xcode ide 中?
- iOS:更新到 Xcode 8.3 后,编译器中C++警告
- 如何让 clang-3.1 出现在 XCode 的编译器列表中
- 如何指定Xcode链接器的库和Xcode编译器的预处理器指令
- 为什么他的语法正确的程序不能在带有llvm编译器的Xcode IDE上编译?
- Xcode clang编译器中的unsigned long-long意外行为
- 我如何在 Xcode 中使用指定的编译器 GCC-MP-4.7
- 编译器错误 xcode 未声明标识符 C++
- 编译器不允许XCode C++断言重新定义
- CXX编译器标识未知:xcode
- 为什么我的 xCode 编译器输出"lldb"?
- xcode 4.2苹果LLVM编译器3.0是否与c++异常完全兼容
- CMake,选择Xcode编译器
- Xcode使用哪个C/ c++编译器
- GCC 4.7/4.8 作为 Xcode 的 C/C++ 编译器
- 在哪个文件中是 xcode 保存的编译器标志
- C++ CodeBlocks & Xcode 中的编译器错误