delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/28/00:03:17

From: scochran AT shoalsnet DOT com
Newsgroups: comp.lang.c++,comp.lang.c++.moderated,comp.os.msdos.djgpp
Subject: Using one copy of class for many other classes
Date: 27 Jun 1997 09:22:15 -0400
Organization: unknown
Lines: 33
Sender: cppmods AT netlab DOT cs DOT rpi DOT edu
Approved: dietmar DOT kuehl AT uni-konstanz DOT de
Message-ID: <5p0epd$gtj@netlab.cs.rpi.edu>
NNTP-Posting-Host: netlab.cs.rpi.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In C++ I've run into yet another brick wall.  I have a class called arena
that is a 50x50 arena for obstacles and robots (for now anyway).  I'm
running into problems because I only want to have one copy of the arena and
multiple copies of the robots or whatever I want to put.

Would I do it something like this?

int robot::robot(arena arenacopy)
  {
   .
   .
   .
  }

int robot::robofunction(void)
  {
   arenacopy.arenafunction();
  }

Would this work?

Also I have an enum to define the objects in a buffer of the arena would it
be best to derive a class from arena and put all the enum and enum specific
(the ones that use the enums) functions there?

<TIA>
Micah Cochran
scochran AT shoalsnet DOT com



      [ Send an empty e-mail to c++-help AT netlab DOT cs DOT rpi DOT edu for info ]
      [ about comp.lang.c++.moderated. First time posters: do this! ]

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019