codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
// Example for method chaining in C++ class F { private: unsigned int eax; public: F() : eax(0) {} F& lda(unsigned int value) { eax = value; return *this; } F& adc(unsigned int value) { eax += value; return *this; } F& inc() { eax++; return *this;} F& dec() { eax--; return *this;} unsigned int get() { return eax; } }; int main() { F cpu; cout << cpu.lda(10).inc().inc().adc(5).get(); }
Private
[
?
]
Run code
Submit