implemented track fully just need to do test code for it

This commit is contained in:
Pagwin 2024-12-11 12:53:09 -05:00
parent f228430658
commit 474309ba49
No known key found for this signature in database
GPG key ID: 81137023740CA260
2 changed files with 31 additions and 1 deletions

2
.gitignore vendored
View file

@ -1,3 +1,3 @@
i i
s s
t

30
track.cpp Normal file
View 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;
}