Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!hplabs!hp-pcd!hplsla!jima
From: jima@hplsla.HP.COM (Jim Adcock)
Newsgroups: comp.lang.c++
Subject: Re: Support for movable objects in C++
Message-ID: <6590276@hplsla.HP.COM>
Date: 3 Oct 89 18:31:03 GMT
References: <1989Sep30.051559.20644@polyslo.CalPoly.EDU>
Organization: HP Lake Stevens, WA
Lines: 35

//Give an example of the code a compiler would generate for the following? 
//[valid under 2.0 except for the volatile keyword]

#include 

class A
{
public:
  virtual void doSomething();
};
  void A::doSomething()
  {printf("I'm not volatile, don't give me an extra indirection\n");}

volatile class B : public A
{
public:
  virtual void doSomething();
};
  void B::doSomething()
  {printf("I'm volatile, give me an extra indirection\n");}

extern "C" {long lrand48();};

main()
{
  A a;
  B b;
  A* p;

  for (int i=0; i<20; ++i)
  {
    p = (lrand48() & 1) ? &a : &b;
    p->doSomething();
  }
}