C++计算倒数的源码

下边内容内容是关于C++计算倒数的的内容,应该是对各位有较大好处。

创新互联建站-专业网站定制、快速模板网站建设、高性价比响水网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式响水网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖响水地区。费用合理售后完善,十多年实体公司更值得信赖。

#include

using namespace std;

class Var;

class Base {
public:
virtual ~Base() {};
virtual ostream &print(ostream &o) const = 0;
};

ostream &operator<<(ostream &o, const Base &e) { e.print(o); return o; }

class Int : public Base {
const int n;
public:
Int(int m) : n(m) {}
~Int() {}
ostream &print(ostream &o) const { return o << n; }
};

class Var : public Base {
const string var;
public:
Var(string v) : var(v) {}
~Var() {}
ostream &print(ostream &o) const { return o << var; }
};

class Plus : public Base {
public:
~Plus() { delete e1; delete e2; }
ostream &print(ostream &o) const
};

class Times : public Base {
public:
~Times() { delete e1; delete e2; }
{ return new Plus(new Times(e1, e2->d(v)), new Times(e1->d(v), e2)); }
};

class Expr {
public:
};

const Expr operator+(const Expr e1, const Expr e2)
{ return Expr(new Plus(e1.e->clone(), e2.e->clone())); }
{ return Expr(new Times(e1.e->clone(), e2.e->clone())); }

ostream &operator<<(ostream &o, const Expr e) { return o << e.e; }

int main() {
Var vx("x"), va("a"), vb("b"), vc("c");
Expr x(&vx), a(&va), b(&vb), c(&vc);
return 0;
}


网页名称:C++计算倒数的源码
URL链接:http://lszwz.com/article/ppecde.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款