我需要为减法和比较添加一些额外的代码。 我把(bool更大)用于比较。
当我运行此操作并输入1'<' 2比较,它说"无效的操作:< &#34 ;. 并且对于1 = 1,它表示"无效操作:="。 但结果必须是"结果:假"和"结果:True"
我不知道。我知道代码很长但不是那么复杂。如果可以,请给我一些提示。
NewsViewHolder
答案 0 :(得分:0)
第344行:
#include <iostream>
class Soldier{
protected:
const int m_damage;
public:
// explicit will prevent implicit conversions from
// being permitted when constructing Soldier
// see http://en.cppreference.com/w/cpp/language/explicit
explicit Soldier(int damage=5):
m_damage(damage)
{}
int damage() const
{
return m_damage;
}
};
class Warrior: public Soldier{
public:
Warrior()
: Soldier(10)
{}
};
// lets make another subclass which implicitly uses the
// default Soldier constructor.
class Samurai: public Soldier{
public:
Samurai()
{}
};
int main(){
Warrior w;
Samurai s;
std::cout << w.damage() << '\n';
std::cout << s.damage() << '\n';
}
第390行:
void print_usage(char* name) {
fprintf(stderr, "----------------------------------------------------\n");
fprintf(stderr, "Usage: %s base input1 operation input2\n", name);
fprintf(stderr, "base must be number between 2 and 36, inclusive\n");
fprintf(stderr, "input1 and input2 are arbitrary-length integers\n");
fprintf(stderr, "Two operations are allowed '+' and '-'\n");
fprintf(stderr, "----------------------------------------------------\n");
exit(1);
}
现在猜猜它为什么说&#34;操作无效:&#34; ...