Article View: gnu.g++.help
Article #907Is there a libg++-2.7.2
From: JC Magras
Date: Sat, 17 Feb 1996 01:46
Date: Sat, 17 Feb 1996 01:46
826 lines
25660 bytes
25660 bytes
Greeting Gnu hackers,
The g++ INSTALL file says you should install a libg++ library with the same
version number as the compiler, but I cant find libg++-2.7.2 at even
prep.mit.edu.
This is the only problem I can think of that is causing the undefined label
errors for two virtual tables of classes I have defined in the appended
shar'ed file. GameContainer.hxx declares the two clases, one derived from the
other.
**************************
g++ -g -Wall -I/usr/local/lib/g++-include -c GameObject.cxx GameControl.cxx
GameContainer.cxx room.cxx
GameContainer.hxx: In method `class GameContainer & GameContainer::operator
=(const class GameContainer &)':
In file included from GameContainer.cxx:4:
GameContainer.hxx:8: warning: unused parameter `const class GameContainer &
one_container'
GameContainer.hxx: In method `class GameBottle & GameBottle::operator =(const
class GameBottle &)':
GameContainer.hxx:35: warning: unused parameter `const class GameBottle &
one_bottle'
GameContainer.hxx: In method `class GameContainer & GameContainer::operator
=(const class GameContainer &)':
In file included from room.cxx:5:
GameContainer.hxx:8: warning: unused parameter `const class GameContainer &
one_container'
GameContainer.hxx: In method `class GameBottle & GameBottle::operator =(const
class GameBottle &)':
GameContainer.hxx:35: warning: unused parameter `const class GameBottle &
one_bottle'
room.cxx: In function `int main()':
room.cxx:126: warning: initialization to
`basic_string<char,string_char_traits<char> > *' from `const
basic_string<char,string_char_traits<char> > *' discards const
room.cxx:126: warning: initialization to
`basic_string<char,string_char_traits<char> > *' from `const
basic_string<char,string_char_traits<char> > *' discards const
g++ -g -Wall -I/usr/local/lib/g++-include GameObject.o GameControl.o
GameContainer.o room.o -oroom
Undefined first referenced
symbol in file
_vt.13GameContainer GameContainer.o
_._10GameBottle room.o
_vt.10GameBottle GameContainer.o
ld: fatal: Symbol referencing errors. No output written to room
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# Makefile
# GameContainer.cxx
# GameContainer.hxx
# GameControl.cxx
# GameControl.hxx
# GameObject.cxx
# GameObject.hxx
# room.cxx
# This archive created: Fri Feb 16 19:37:22 1996
export PATH; PATH=/bin:$PATH
if test -f 'Makefile'
then
echo shar: will not over-write existing file "'Makefile'"
else
cat << \SHAR_EOF > 'Makefile'
CC=g++
GPPINCLUDE=/usr/local/lib/g++-include
CFLAGS=-g -Wall -I${GPPINCLUDE}
default:: objects GameObject.cxx GameControl.cxx GameContainer.cxx
${CC} ${CFLAGS} GameObject.o GameControl.o GameContainer.o room.o
-oroom
SRCS=GameObject.cxx GameControl.cxx GameContainer.cxx
HEADERS=${SRCS:.cxx=.hxx}
objects:: room.cxx ${SRCS} ${HEADERS}
${CC} ${CFLAGS} -c ${SRCS} room.cxx
clean:
-rm room
uninstall:
-rm /usr/local/bin/rooms
SHAR_EOF
fi # end of overwriting check
if test -f 'GameContainer.cxx'
then
echo shar: will not over-write existing file "'GameContainer.cxx'"
else
cat << \SHAR_EOF > 'GameContainer.cxx'
#define estring string
#include <string>
#include <iostream.h>
#include "GameContainer.hxx"
//Default Constructor for no Paramaters
GameContainer::GameContainer(void) { item_count=0;contents[0]=0; }
// Destructor
GameContainer::~GameContainer()
{
int index;
for (index=0;index < this->item_count;index++) {
delete contents[index];
}
}
// Constructor GameObject from another GameObject
GameContainer::GameContainer (const GameObject &old_game_object) {
contents[0]=new GameObject(old_game_object);
this->GameObjectName=new string("bucket");
}
// Constructor GameObject from a name and a unsigned array of attributes
GameContainer::GameContainer(const string &ObjectName ,
unsigned long int ObjectFlags[]) {
contents[0]=new GameObject(ObjectName,ObjectFlags);
item_count=1;
}
ostream &operator << (
ostream &out_file ,
const GameContainer &thisBox
)
{
int index;
for (index=0;index < thisBox.item_count;index++) {
out_file << string("a " )
<< (const estring &)
*((thisBox.contents[0])->GameObjectName)
<< string("\n");
// (const estring &)game_piece.get_contents(game_piece) <<
"\n";
}
return (out_file);
}
/*
const string & get_contents(const GameContainer &jug)
{ return ((const string &) (jug.contents[0]->GameObjectName)); }
*/
ostream &operator << (
ostream &out_file,
const GameBottle &thisBottle
)
{
string c_which_con(" which contains ") ;
string c_of(" of ");
//if (game_piece.contents == 0) { return (out_file) };
out_file << *(thisBottle.GameObjectName)
<< c_which_con;
if (thisBottle.current_load!=LONG_MAX)
out_file << (unsigned) (thisBottle.current_load);
else
out_file << 1000;
out_file << " "
<< (string ) (thisBottle.units)
<< c_of
<< (string ) *((thisBottle.contents[0])->GameObjectName) << "\n";
return (out_file);
}
/*
const estring &GameBottle::get_contents(const GameBottle &jug)
{ return ((const estring &) (jug.contents[0]->GameObjectName)); }
*/
GameBottle::GameBottle():GameContainer() {max_capacity = 2000;
current_load=0; item_count=0; }
GameBottle::GameBottle( const GameObject &what,
signed long initial_load,
unsigned long max_cap=1000 ):GameContainer(what)
{
contents[0]=new GameObject(what);
this->max_capacity = max_cap;
if (initial_load == QUA_INF) {
this->max_capacity=LONG_MAX;
this->current_load=LONG_MAX;
}
else
this->current_load=initial_load;
}
GameBottle::GameBottle(
const estring what,
unsigned long int flags[],
signed long initial_load,
unsigned long max_cap=1000
):GameContainer(what,flags)
{
contents[0]=new GameObject(what,flags);
this->max_capacity = max_cap;
if (initial_load == QUA_INF) {
this->max_capacity=LONG_MAX;
this->current_load=LONG_MAX;
}
else
this->current_load=initial_load;
}
GameBottle &operator += (
GameBottle &game_piece,
const GameBottle &resupply
)
{
//if (game_piece.what == resuppply.what) ;
if (resupply.max_capacity==LONG_MAX) {
game_piece.current_load=1000;
}
else if((game_piece.current_load + resupply.current_load) >
game_piece.max_capacity) {
game_piece.current_load=1000;
} else {
game_piece.current_load += resupply.current_load;
}
return game_piece;
}
GameBottle &operator -= (
GameBottle &game_piece ,
const GameBottle &withdrawl
)
{
//if (game_piece.what == withdrawl.what) ;
if (withdrawl.max_capacity==LONG_MAX) {
game_piece.current_load=game_piece.max_capacity;
} else if (
( withdrawl.current_load -
(game_piece.max_capacity-game_piece.current_load)) < 0 ) {
game_piece.current_load -= withdrawl.current_load;
} else
game_piece.current_load=0;
return game_piece;
}
SHAR_EOF
fi # end of overwriting check
if test -f 'GameContainer.hxx'
then
echo shar: will not over-write existing file "'GameContainer.hxx'"
else
cat << \SHAR_EOF > 'GameContainer.hxx'
#ifndef _GAME_CONTAINER_H
#define _GAME_CONTAINER_H
#define QUA_INF -1
#define estring string
#include <limits.h>
#include "GameObject.hxx"
class GameContainer:public GameObject {
GameContainer &operator = (const GameContainer &one_container) {
return (*this);
};
protected:
unsigned short item_count;
//GameControl *dials;
public:
GameObject **contents;
//const string &get_contents(const GameContainer &jug) const;
virtual unsigned short get_percentage_full(void);
GameContainer(void) ;
GameContainer(const estring ObjectName);
GameContainer (const GameObject &old_game_object) ;
GameContainer(const string &ObjectName , unsigned long int
ObjectFlags[]);
virtual ~GameContainer(void);
friend ostream &operator << ( ostream &out_file,
const GameContainer &game_piece);
};
class GameBottle:public GameContainer {
GameBottle &operator = (const GameBottle &one_bottle) { return (*this);
};
protected:
// GameObject **contents;
signed long int max_capacity;
signed long int current_load;
const estring units("milliliters");
//GameControl *dials;
public:
//GameObject **contents;
//const string &get_contents(const GameBottle &jug) ;
unsigned short get_percentage_full(void);
GameBottle(); // { max_capacity = 2000; current_load=0; item_count=0;};
GameBottle( const estring what,
unsigned long int flags[],
signed long inital_load,
unsigned long max_cap=1000);
GameBottle( const GameObject &what,
signed long inital_load,
unsigned long max_cap=1000 );
virtual ~GameBottle() { if (contents[0]) {
delete contents[0];
}
item_count=0;
};
friend GameBottle &operator += (GameBottle &game_piece,
const GameBottle &resupply);
friend GameBottle &operator -= (GameBottle &game_piece,
const GameBottle &withdrawl);
friend ostream &operator << (ostream &out_file,
const GameBottle &game_piece);
};
#endif
SHAR_EOF
fi # end of overwriting check
if test -f 'GameControl.cxx'
then
echo shar: will not over-write existing file "'GameControl.cxx'"
else
cat << \SHAR_EOF > 'GameControl.cxx'
#define estring string
#include <string>
#include "GameControl.hxx"
/*ostream &GameControl::operator << ( ostream &out_file)
{
out_file << *(this->settings[this->current_state]);
return (out_file);
}
*/
GameControl::GameControl(
const string name,
estring *settings[],
unsigned long int attributes[],
const estring *machine,
unsigned int start=es_Start
) :GameObject(name,attributes+sizeof(unsigned long))
{
GameControl::settings=settings;
GameControl::FSA=machine;
GameControl::controlname=new estring(name.data());
GameControl::current_state=start;
GameControl::number_of_states=attributes[0];
}
ostream &operator << ( ostream &out_file, const SlotDevice &thisSlot)
{
out_file << *(thisSlot.settings[thisSlot.current_state]);
return (out_file);
}
SHAR_EOF
fi # end of overwriting check
if test -f 'GameControl.hxx'
then
echo shar: will not over-write existing file "'GameControl.hxx'"
else
cat << \SHAR_EOF > 'GameControl.hxx'
#ifndef _GAME_CONTROL_H
#define _GAME_CONTROL_H
#define estring string
#include <iostream.h>
#include "GameObject.hxx"
class GameControl : public GameObject {
protected:
unsigned long int current_state;
private:
unsigned int number_of_states;
const estring *controlname;
const estring *FSA;
public:
estring **settings;
enum {es_Start=0,es_Middle=1,es_Final=100,e_state_count=3};
enum {
e_pushable=1,
e_receptacle=2,
e_post_turnable=4,
e_turnable=8,
e_pullable=16,
e_squeeze=32
};
enum {
e_evt_insert=1,
e_evt_turn=2,
e_evt_push=4,
e_evt_pull=8,
e_evt_squeeze=16
};
enum {
e_resp_nothing=1,
e_resp_death=2,
e_resp_new_state=4,
e_resp_transport=8,
e_resp_suspend=16
};
bool IsInFinalState() { return (GameControl::current_state ==
GameControl::es_Final);};
int process_input( unsigned event_code,
estring destination,
estring *aux_data);
virtual ~GameControl() { cout << "Game Control Destructor called\n"; };
GameObject ();
GameControl (const GameControl &instance);
GameControl(const string name,
estring *settings[],
unsigned long int attributes[],
const estring *machine,
unsigned int start=es_Start);
friend ostream &operator << ( ostream &out_file,
const GameControl &control );
};
class SlotDevice : public GameControl {
protected:
//unsigned long int current_state;
public:
// enum {es_Start=0,es_Middle=1,es_Final=100,e_state_count=3};
enum {
e_receptacle=2,
};
enum {
e_evt_insert=1,
};
enum {
e_resp_nothing=1,
e_resp_death=2,
e_resp_new_state=4,
e_resp_transport=8,
e_resp_suspend=16
};
bool IsInFinalState() { return (SlotDevice::current_state ==
SlotDevice::es_Final);};
//int process_input( unsigned event_code,
// estring destination,
// estring *aux_data);
virtual ~SlotDevice() { cout << "Slot Device Destructor called\n"; };
SlotDevice ();
SlotDevice (const SlotDevice &instance);
SlotDevice (
const estring name,
estring *settings[],
unsigned long int attributes[],
const estring *machine,
unsigned int start=es_Start):GameControl(name,
settings,
attributes,
machine,
start) { };
friend ostream &operator << ( ostream &out_file ,
const SlotDevice &control );
};
#endif
SHAR_EOF
fi # end of overwriting check
if test -f 'GameObject.cxx'
then
echo shar: will not over-write existing file "'GameObject.cxx'"
else
cat << \SHAR_EOF > 'GameObject.cxx'
#define estring string
#include <string>
#include "GameObject.hxx"
ostream &operator << ( ostream &out_file, const GameObject &game_piece );
ostream &operator << (
ostream &out_file ,
const GameObject &game_piece
)
{
const string a_("a ");
out_file << a_ << *(game_piece.GameObjectName);
return (out_file);
}
/*
GameObject & GameObject::operator = (const GameObject &old_game_object) {
GameObject new_object(old_game_object);
return (new_object);
}*/
GameObject::GameObject (const GameObject &old_game_object) {
GameObjectAttributes[0]=old_game_object.GameObjectAttributes[0];
this->GameObjectName = old_game_object.GameObjectName;
}
GameObject::GameObject (
const estring ObjectName,
unsigned long int ObjectFlags[]
)
{
this->GameObjectName=new estring(ObjectName.data());
GameObjectAttributes[0]=ObjectFlags[0];
}
GameObject::GameObject ( ) {
GameObjectName=new estring("");
GameObjectAttributes[0]=0;
}
SHAR_EOF
fi # end of overwriting check
if test -f 'GameObject.hxx'
then
echo shar: will not over-write existing file "'GameObject.hxx'"
else
cat << \SHAR_EOF > 'GameObject.hxx'
#ifndef _GAME_OBJECT_H
#define _GAME_OBJECT_H
#define estring string
#include <string>
class GameObject {
protected:
enum {
NumberOfAttributes=10,
SizeOfGameObjectName=16*sizeof(unsigned long)
};
unsigned long int \
GameObjectAttributes[NumberOfAttributes/sizeof(unsigned long)];
public:
const estring *GameObjectName;
enum { GaObjStOpen=1,
GaObjAttrOpenable=2,
GaObjAttrWeapon=4,
GaObjAttrHandHeld=8,
GaObjAttrCrewofOne=16,
GaObjAttrNoLoad=32,
GaObjAttrWearable=64,
GaObjAttrRope=128,
GaObjAttrArmor=256,
GaObjAttrPaper=512,
GaObjAttrHasArea=1024,
GaObjAttrGlass=2048,
GaObjAttrBronze=4096,
GaObjAttrLiquidHold=8192,
GaObjAttrFood=16384,
GaObjAttrStone=32768,
GaObjAttrImmoveable=65536,
GaObjAttrDispenser=65536*2,
GaObjAttrAccessTool=65536*4
};
const string Documentation( \
"This is the GameObject.It defines
GaObjStOpen,GaObjAttrOpenable,GaObjAttrWeapon,GaObjAttrHandHeld,GaObjAttrCrew
ofOne,GaObjAttrNoLoad,GaObjAttrWearable,GaObjAttrRope,GaObjAttrArmor,GaObjAtt
rPaper,GaObjAttrHasArea,GaObjAttrGlass,GaObjAttrBronze,GaObjAttrLiquidHold,Ga
ObjAttrFood as enums. Function GaObjectIsOpen is a public member function.");
GameObject &operator = (const GameObject &old_game_object) const;
GameObject (const GameObject& old_game_object) ;
GameObject (estring ObjectName,
unsigned long int *ObjectFlags ) ;
GameObject ( ) ;
virtual ~GameObject () { } ;
int GaObjectIsOpen(void) {
return ( GameObjectAttributes[0] & GaObjStOpen );
};
friend ostream &operator << ( ostream &out_file,
const GameObject &game_piece );
// GameObject &operator [] ( const unsigned int index );
};
ostream &operator << ( ostream &out_file,const GameObject &game_piece );
#endif
SHAR_EOF
fi # end of overwriting check
if test -f 'room.cxx'
then
echo shar: will not over-write existing file "'room.cxx'"
else
cat << \SHAR_EOF > 'room.cxx'
#include <iostream.h>
#include <string>
#include <limits.h>
#include "GameControl.hxx"
#include "GameContainer.hxx"
//#include "estring.hxx"
#define estring string
#define QUA_INF -1
GameBottle::GameBottle( const estring what,
unsigned long int flags[],
signed long inital_load,
unsigned long max_cap=1000);
GameBottle::GameBottle( const GameObject &what,
signed long inital_load,
unsigned long max_cap=1000 );
class GameLocation {
GameContainer **LocContents;
GameObject **LocObjects;
const estring *locname;
const estring *loc_description;
unsigned int local_flags[8];
GameLocation::SetAbsCoordinates();
GameLocation::SetExits();
public:
draw_outside();
draw_inside();
estring &GameLocation::GetAbsCoordinates();
estring &GameLocation::GetExits();
GameLocation(const GameLocation &room);
GameLocation(const estring *texts[],
GameContainer **things,
GameObject **contents);
can_access_objects();
bool GameLocation::can_enter();
bool GameLocation::can_exit();
bool GameLocation::magic();
friend ostream &operator << (ostream &out_file, const GameLocation
&there);
};
GameLocation::GameLocation (
const estring *texts[],
GameContainer **things,
GameObject **content
) {
GameLocation::LocContents=things;
GameLocation::LocObjects=content;
this->locname=texts[0];
this->loc_description=texts[1];
}
ostream& operator << (ostream &out_file,const GameLocation &there ){
out_file << *(there.locname) << "\n";
out_file << *(there.loc_description);
if (there.LocObjects != 0) {
out_file << " There is " << *((there.LocObjects[0])->GameObjectName) <<
" here.";
}
if (there.LocContents != 0) {
out_file << " There is " << *((there.LocContents[0])->GameObjectName) <<
" here.";
}
out_file << "\n";
return (out_file);
}
main () {
unsigned int index;
unsigned long int Gameattr[1]={
GameObject::GaObjAttrOpenable | GameObject::GaObjAttrWearable
};
unsigned long int swordattr[1]={
GameObject::GaObjAttrNoLoad | GameObject::GaObjAttrWeapon |
GameObject::GaObjAttrHandHeld | GameObject::GaObjAttrCrewofOne |
GameObject::GaObjAttrBronze
};
unsigned long BreastPlateAttr[1] = {
GameObject::GaObjAttrWearable | GameObject::GaObjAttrArmor
};
unsigned long MapAttr[1]={
GameObject::GaObjAttrPaper | GameObject::GaObjAttrHasArea
};
unsigned long RopeAttr[1]= { GameObject::GaObjAttrRope };
unsigned long decanterAttr[1]={
GameObject::GaObjAttrGlass | GameObject::GaObjAttrOpenable |
GameObject::GaObjAttrLiquidHold
};
unsigned long fountainAttr[1]={
GameObject::GaObjAttrStone | GameObject::GaObjAttrImmoveable |
GameObject::GaObjAttrDispenser
};
unsigned long playerAttr[1]={0};
unsigned long keyAttr[1]={
GameObject::GaObjAttrBronze|GameObject::GaObjAttrAccessTool
};
unsigned long HeliCardSlotAttr[2]={
GameControl::e_receptacle,GameObject::GaObjAttrAccessTool
};
unsigned HeliStartState=GameControl::es_Start;
const estring n_ring("ring");
const estring n_sword("sword");
const estring n_rope("rope");
const estring n_BreastPlate("BreastPlate");
const estring n_map("Treasure Map");
const estring n_vessel("vessel");
const estring n_water("water");
const estring n_player("Participant");
const estring n_key("Brass Key");
const estring n_pad("Landing Pad");
const estring d_pad("This is obviously a Helicopter pad as there is a
helicopter sitting here. The helicopter has a door built into it on each
side. There is an exit down a set of stairs.");
const estring d_inside_helicopter("You are inside the helocopter,sitting
in on of two seats. In front of and between your knees, there is a long
joystick. There is also a large set of gauges on a control panel in front of
you. There is a twistable lever arm between the two seats.");
const estring d_island_hpad("This is another helipad but it is on an
island. There is a large rectangular building at the end of a brick walkway,
down and to the northwest. In the roof of the building, you can see what seem
to be doors taking up most of the space of the roof. There is a sign saying
`Hanger 17` over the door way at the end of the walkway.");
const estring n_island_hpad("Island helipad");
const estring d_full_fuel("The fuel gauges seem to say full.");
const estring *room_texts[2]={&n_pad,&d_pad};
const estring stand_by("There is an empty card slot in the panel. The
light above is off."),
ready("There is a card in the slot on the panel and above, a light is
lit.");
estring *settings[2]={&stand_by,&ready};
const estring Heli_slot("Incert Helikopter Akces Kard");
const estring m_Helislot("");
const estring n_inside_Heli("Inside Helicopter");
GameObject vessel(n_vessel,decanterAttr);
GameObject fountain(n_vessel,fountainAttr);
GameObject ring(n_ring,Gameattr);
GameObject sword(n_sword,swordattr);
GameObject rope(n_rope,RopeAttr);
GameObject BreastPlate(n_BreastPlate,BreastPlateAttr);
GameObject map(n_map,MapAttr);
GameObject key(n_key,keyAttr);
GameObject *inventory[]={&ring,&sword,&rope,&BreastPlate,&map};
GameObject stomach(n_player,playerAttr);
GameBottle decanter(vessel,67,1500) ;
GameBottle player1(stomach,10,1750) ;
GameBottle water_fountain(fountain,QUA_INF,2400) ;
GameObject *things={&key};
GameContainer *pans={&water_fountain};
GameLocation room(room_texts,&pans,&things);
const estring *Helicopter_texts[2]={&n_inside_Heli,&d_inside_helicopter};
GameLocation helicopter(Helicopter_texts ,(GameContainer**)NULL
,(GameObject**)NULL);
GameObject test(Heli_slot, &HeliCardSlotAttr[1]);
SlotDevice HeliPanel( Heli_slot,
settings,
HeliCardSlotAttr,
&m_Helislot,
HeliStartState);
for (index=0;index < sizeof(inventory)/sizeof(GameObject*);index++) {
cout << (*inventory[index]) << "\n" ;
}
cout << '\n';
cout << decanter;
cout << '\n';
cout << player1;
cout << '\n';
decanter +=water_fountain;
for (index=0;index < sizeof(inventory)/sizeof(GameObject*);index++) {
cout << *(inventory[index]) << "\n" ;
}
cout << '\n';
cout << decanter;
cout << '\n';
player1 += decanter;
for (index=0;index < sizeof(inventory)/sizeof(GameObject*);index++) {
cout << *(inventory[index]) << "\n" ;
}
cout << '\n';
cout << decanter;
cout << '\n';
cout << player1;
cout << '\n';
cout << room;
cout << '\n';
cout << helicopter;
cout << HeliPanel;
}
SHAR_EOF
fi # end of overwriting check
# End of shell archive
exit 0
Technical Details
Message-ID:
<4g3c2j$3ug@news.onramp.net>Path:
arc1-ca.pugleaf.net!news.onramp.net!usenetShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.onramp.net!usenet From: magras@suite.com (JC Magras) Newsgroups: gnu.g++.help,comp.lang.c++ Subject: Is there a libg++-2.7.2 Date: 17 Feb 1996 01:46:58 GMT Organization: On-Ramp; Individual Internet Connections; Dallas/Ft Worth/Houston, TX USA Message-ID: <4g3c2j$3ug@news.onramp.net> NNTP-Posting-Host: s175-18.suite.com