Skip to content

Commit

Permalink
Subscript operator overloading for num
Browse files Browse the repository at this point in the history
  • Loading branch information
aarikpokras authored Jan 1, 2025
1 parent c61d863 commit 9ceed6d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/io.cxlbund/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ struct num {
return false;
}
}
num operator[](const int& o) {
std::string ret__ = std::to_string(c);
std::string ret_ = std::string(1, ret__[o]);
double ret = std::stod(ret_);
return num(ret);
}
num operator+(const num& o) {
return num(c + o.c);
}
Expand Down

0 comments on commit 9ceed6d

Please sign in to comment.