Topic: trouble defining operator[][]
Author: cdacgrp@cse.iitb.ernet.in (CDACProject)
Date: Mon, 29 Mar 1993 14:20:40 GMT Raw View
Hi there,
I'd like to know whether operator[][] is a part of C++. It should be
a part of C++ because, it does not mutate the language definition.
In case it is so, please tell me how to define operator[][]...[].
Please send your mail to:-
cdacgrp@kailash.cse.iitb.ernet.in
Thank you
(Kamal)
Author: b91926@fnclub.fnal.gov (David Sachs)
Date: 29 Mar 93 22:59:25 GMT Raw View
In article <1993Mar29.142040.24182@cse.iitb.ernet.in>, cdacgrp@cse.iitb.ernet.in (CDACProject) writes:
|>
|> Hi there,
|>
|> I'd like to know whether operator[][] is a part of C++. It should be
|> a part of C++ because, it does not mutate the language definition.
|> In case it is so, please tell me how to define operator[][]...[].
|>
|> Please send your mail to:-
|> cdacgrp@kailash.cse.iitb.ernet.in
|>
|> Thank you
|> (Kamal)
|>
operator[][] is NOT part of c++. However you CAN use double subscripting. Essentially an expression like a[b][c] is treated like:
(a.operator[](b)).operator[](c)
or (a[b])[c]
In other words a[b] must mean something for which [] is a valid operator.
Author: jimad@microsoft.com (Jim Adcock)
Date: 30 Mar 93 21:22:53 GMT Raw View
In article <1993Mar29.142040.24182@cse.iitb.ernet.in> cdacgrp@cse.iitb.ernet.in (CDACProject) writes:
| I'd like to know whether operator[][] is a part of C++.
operator[][] is not a part of C++, because '[][]' is not a C++
operator. operator[](sometype) is a part of C++ because '[]' is
a part of C++. The effect of operator[][] -- if it were to
exist -- can be simulated by writing operator[] to return a
reference or pointer to an array-like object that in turn has
an operator[] defined for it. Good C++ texts should cover
this issue.