Re: [問題] 九九乘法表不用迴圈是叫我直接從1列到81?

作者: PkmX (阿貓)   2018-07-17 04:49:45
http://coliru.stacked-crooked.com/a/fba5b7b3b253288d
#include <iostream>
#include <string>
struct table {
std::string s;
table() {}
~table() { std::cout << this->s; }
table(const int n) : s{std::to_string(n)} {}
table(std::string&& s_) : s{std::move(s_)} {}
table(table&& other) : s{other.take()} {}
table operator=(const int n) { return this->take() + " = " + std::to_string(n); }
table operator=(table&& rhs) { return this->take() + " = " + rhs.take(); }
std::string take() { const auto s = this->s; this->s.clear(); return s; }
bool empty() const { return this->s.empty(); }
const char& back() const { return this->s.back(); }
};
table operator++(table&& t, int) { return t.take(); }
table operator
作者: cutekid (可愛小孩子)   2018-07-17 10:37:00
猛猛的!
作者: MOONRAKER (㊣牛鶴鰻毛人)   2018-07-17 15:30:00
太棒了這樣code和document和result都合一了(?)
作者: shadow0326 (非議)   2018-07-17 15:58:00
specification by example
作者: Schottky (順風相送)   2018-07-17 16:31:00
所見即所得
作者: lucky1lk (賭到沒錢的人)   2018-07-17 16:50:00
強 給推 未必有人看得懂XDDD
作者: descent (「雄辯是銀,沉默是金」)   2018-07-17 17:07:00
看不懂
作者: BlazarArc (Midnight Sun)   2018-07-17 23:47:00
XDDDDDDDDDD
作者: lc85301 (pomelocandy)   2018-07-20 00:32:00
猛XDD
作者: dou0228 (7777)   2018-07-23 08:42:00
比 template 好懂多了 XDD

Links booklink

Contact Us: admin [ a t ] ucptt.com