Path: utzoo!attcan!uunet!mcvax!cernvax!ethz!peter From: peter@ethz.UUCP (Peter Beadle) Newsgroups: comp.lang.c++ Subject: overloading array indexing Keywords: [] bugs? array indexing Message-ID: <451@ethz.UUCP> Date: 13 May 88 16:22:05 GMT Organization: ETH Zuerich Lines: 41 I have been trying to overload the array indexing operation as part of a simulator I am writing. I am getting nowhere fast. I have a small program below and the C code it produces. The translator produces a _tiny__vec function when I don't inline the overload. This function contains the correct code but it never gets called in main. Similarly when the overload is inlined nothing but a reference to the name of the array is produced in main. This is the smallest example I can produce. Anybody got any ideas. Peter Beadle peter@eiger.uucp mcvax!cernvax!iis!peter /* test program */ #include class tiny{ int v; public: tiny() {v=0;} void operator[](int i) { cerr << "in overloaded []\n"; } }; main() { tiny fred[5]; fred[2]; } /* the main program it produces */ int main (){ _main(); { struct tiny _auto_fred [5]; _vec_new ( (int *)_auto_fred , 5, 4, (int *)_tiny__ctor ) ; _auto_fred ; } };