pingus-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

References are evil...


From: Ingo Ruhnke
Subject: References are evil...
Date: 10 Sep 2002 15:21:11 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Ok, some hugly hacks are fireing back:

class SpriteEditorObj : public RectEditorObj
{
protected:
  Sprite sprite;
  CL_Vector& pos_ref;

  SpriteEditorObj (CL_Vector& arg_pos);

[...]

void
SpriteEditorObj::operator= (const SpriteEditorObj& old)
{
  if (this != &old)
    {    
      RectEditorObj::operator=(old);
  
      sprite  = old.sprite;
      pos_ref = old.pos_ref;
    }
}

[...]

SmasherObj::SmasherObj (const WorldObjsData::SmasherData& data_)
  : SpriteEditorObj(data_.pos),
    frame(0),
    data(new WorldObjsData::SmasherData(data_))
{


SpriteEditorObj(data_.pos) <- this is obviously wrong and a lot of
other classes suffer the same problem.

So how to we fix this? Quick&dirty by converting the reference into a
pointer? Or by poluting the whole stuff with getter and setter
methods?

-- 
WWW:      http://pingus.seul.org/~grumbel/ 
Games:    http://pingus.seul.org/~grumbel/gamedesigns/
JabberID: address@hidden 
ICQ:      59461927




reply via email to

[Prev in Thread] Current Thread [Next in Thread]