J
jeroendeurinck
Hi all,
I'm a newbe, so sorry if this question would be inappropriate here.
Nevertheless I try.
---
Suppose I have a class CTraffic in which several objects of class
CVehicle move around. However, class CVehicle is an abstract base
class, since every object of it is member of subclass CCar or subclass
CBicycle.
So if I define a CVehicle inside CTraffic, I can make an if/else block
that decides if we're on the main road or on the bicycle path. Inside
this block I can then declare and initialize the right object as
CCar* pVehicle = new CCar();
or
CBicycle* pVehicle = new CBicycle();
and afterwards perform some CVehicle functions (like MoveFroward(int
dist)) on my new pointer pVehicle.
---
However, something seams to be wrond with this concept, because
debugging gives an error
error C2065: 'pBac' : undeclared identifier
on the line where I first use the new pVehicle object outside the
if/else block.
For any help or effort: thx in advance!!!
j
I'm a newbe, so sorry if this question would be inappropriate here.
Nevertheless I try.
---
Suppose I have a class CTraffic in which several objects of class
CVehicle move around. However, class CVehicle is an abstract base
class, since every object of it is member of subclass CCar or subclass
CBicycle.
So if I define a CVehicle inside CTraffic, I can make an if/else block
that decides if we're on the main road or on the bicycle path. Inside
this block I can then declare and initialize the right object as
CCar* pVehicle = new CCar();
or
CBicycle* pVehicle = new CBicycle();
and afterwards perform some CVehicle functions (like MoveFroward(int
dist)) on my new pointer pVehicle.
---
However, something seams to be wrond with this concept, because
debugging gives an error
error C2065: 'pBac' : undeclared identifier
on the line where I first use the new pVehicle object outside the
if/else block.
For any help or effort: thx in advance!!!
j