🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2254

Need an operator ->[]

#2254
From: Shashaanka
Date: Wed, 18 Oct 1995 04:24
41 lines
1833 bytes
I have following scenario

class X {

  public:
     int operator [](int);
      ....
      .....
   };

X x;
X * x1=x;

I want to use X.operator[] via x1. That would mean that I will have to use following
syntax:

(*x1)[10] to access 10th element.

However, a more natural way could be to use it like
x1->[10].

Would like your comments on this, or if there are alternatives.

Just for those, who want to know, why I have to use like this is that I am creating
various vector and other objects in the shared memory. Now various processes 
interfacing this can access these objects via pointers interfaces to the shared 
memory. 

Basically, I wanted to use shared memory as program heap, with my own memory 
management. Lot of details are missing from above example, however, if anyone wants,
I can provide them.

Would appreciate your ideas, comments and if any better solutions you have in mind.

Thanks



[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <461ref$hfr@sake.wwa.com>
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage
References: <45tv4c$opc@news.csus.edu> <45uf98$dqt@jabba.lehman.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage
From: Shashaanka <shashank@sashimi.wwa.com>
Newsgroups: comp.std.c++
Subject: Need an operator ->[]
Date: 18 Oct 1995 04:24:16 GMT
Organization: WorldWide Access - Chicagoland Internet Services
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <461ref$hfr@sake.wwa.com>
References: <45tv4c$opc@news.csus.edu> <45uf98$dqt@jabba.lehman.com>
NNTP-Posting-Host: taumet.eng.sun.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Nntp-Posting-Host: vh3-019.wwa.com
X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
Content-Length: 909
Originator: clamage@taumet