implemented track fully just need to do test code for it
This commit is contained in:
parent
f228430658
commit
474309ba49
2 changed files with 31 additions and 1 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,3 @@
|
|||
i
|
||||
s
|
||||
|
||||
t
|
||||
|
|
30
track.cpp
Normal file
30
track.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include <iostream>
|
||||
#include <ostream>
|
||||
class A {
|
||||
long long counter = 0;
|
||||
|
||||
public:
|
||||
A() : counter{0} {}
|
||||
A operator()() {
|
||||
A ret = *this;
|
||||
ret.counter++;
|
||||
return ret;
|
||||
}
|
||||
A operator[](int dummy) {
|
||||
A ret = *this;
|
||||
ret.counter--;
|
||||
return ret;
|
||||
}
|
||||
friend std::ostream &operator<<(std::ostream &lhs, A const &rhs) {
|
||||
lhs << rhs.counter;
|
||||
return lhs;
|
||||
}
|
||||
};
|
||||
|
||||
int main(void) {
|
||||
A a;
|
||||
std::cout << a[0] << std::endl;
|
||||
std::cout << a[0]() << std::endl;
|
||||
std::cout << a[0]()() << std::endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue