🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++
Article #457

overloading operator->

#457
From: Per Mildner
Date: Wed, 31 May 1989 17:47
34 lines
1216 bytes
I wan't an object to be treated as a pointer by operator->. Below is an outline
of what i'm trying to do. I've tried several variants in the places marked '??'
but they don't seem to work. I understand that operator-> has some new meaning
attached to it recently but haven't seen it explained. The messages produced by
g++ (1.35.0 & 1.35.1-) give little indication as to what goes on, eg. 'inline
declaration ignored for function taking (...)' or some such.

class Object {
public:
  int a;
};

class Pointer {
  int data;
public:
  Object* p;
  ?? operator ->();
};

inline ?? operator ->() {
  return ?? p;
};

int main (int argc, char* argv[]) {
  Object O;
  Pointer P;
  P.p = &O;
  P->a = 10;
  return P->a;
};

// I'm Per-Mildner@AIDA.CSD.UU.SE
// I wonder if I sen't this to the rigth place.
Technical Details
Message-ID: <8905311747.AA04206@mizar.DoCS.UU.SE>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ukma!tut.cis.ohio-state.edu!mizar.docs.uu.se!perm

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ukma!tut.cis.ohio-state.edu!mizar.docs.uu.se!perm
From: perm@mizar.docs.uu.se (Per Mildner)
Newsgroups: gnu.g++
Subject: overloading operator->
Message-ID: <8905311747.AA04206@mizar.DoCS.UU.SE>
Date: 31 May 89 17:47:55 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 34