cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
operator overloading
operator overloading
Jan 16, 2013 at 5:31pm UTC
ljs
(48)
Hi hi,
is it possible to use operator overloading to overload an "[][]" operator instead of just "[]" ?
What I would like is that upon reading
myContainer[i][j]
the program would go to a member function of the class that myContainer belongs to
and pass it the arguments i and j.
Jan 16, 2013 at 5:34pm UTC
firedraco
(6243)
No. You would have to use a proxy type or something. Just overload operator() instead.
Jan 16, 2013 at 6:02pm UTC
Marcos Modenesi
(129)
Is it "[][]" really a different operator than "[]"? Intuitively I guess it´s just the same thing twice: serching for an index inside something that´s been pulled out of an index as well...
http://www.learncpp.com/cpp-tutorial/98-overloading-the-subscript-operator/
Topic archived. No new replies allowed.