maadhuu wrote:
why can't you have an array of references ???
Because references are not "things". They are not objects; you can't point
to them, take their addresses, etc.
Naturally, many situations implement them as invisible pointers. However, if
the C++ Standard allowed any syntax more that forced them to become
"invisible pointers", such law would limit the kinds of optimizations
compilers can subject them to. You can't point to a reference, and index
addressing is explicitely defined as a form of pointing-to.
The next question should be this: What benefit can you expect to derive from
an array of references. If you need to replace -> with ., then look to your
own interface, not to the Standard. Here's pseudo-C++ showing such an
interface:
class Things
{
private:
std::vector<Thing *> things;
public:
Thing & operator[] (int idx)
{
Thing * pThing = things[idx];
assert(pThing);
return *pThing;
}
};
--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand