Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

subscript operator in C++

is subscript operator [ ] unary or binary operator ?

I'm quite new to C++ and was going through operator operloading and wondered is subscript a unary or binary?


1 Answers

The subscript operator is a binary operator in the strict sense as it takes two arguments, the reference to the object and the value.

int arr[3];

Here you can see that [] operator makes use of both arr and 3.

like image 140
Nivetha Avatar answered Oct 19 '25 17:10

Nivetha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!