Fallible point in C/C++

Operator[]

The performance of [] in C and C++ is different.
e.g., when you excute A[index]

  • If A is a object, it will call the operator[]
  • If A is a pointer, it is equivalent to A + index

So, operator overloading is invalid to pointer.

posted @ 2023-09-22 21:47  0x7F  阅读(2)  评论(0编辑  收藏  举报