Inheritance

Hey guys I have a problem with Inheritance
I have these classes but they dont want ot inherit correctly.Please help

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

enum PieceType{BOULDER}
  class Piece
{
Piece(int m, PieceType t)// PieceType is an enumeration 
{
max = m;
type = t;
}
PieceType getType() const
{
return type;
}
}



class BigPiece : public Piece
{
BigPiece(int m, PieceType t): Pice(m, l){}

}



class smallPiece : public BigPiece
{

smallPiece(char _type) : BigPiece(5, BOULDER)
{
	
	boulderType = _type;
}

}

cha getBoulderType() const
{
	return boulderType;
}
class test
{
Piece * l;

l->getBoulderType(); // there error is here.It says that Piece doesnt have a member named getBoulderType
}


Edit*
Plesae help
Last edited on
You forgot the access specifiers.

There are three that you can use, and they appear as labels:
public private protected

For example:
1
2
3
4
5
6
7
8
9
class BigPiece : public Piece
{
public: // everything below is public, until a new label is found

BigPiece(int m, PieceType t): Pice(m, l){}

private:
int x; // x is private, and so is everything below...
}

http://www.cplusplus.com/doc/tutorial/classes/
Sory.Those are fine.I just wrote a sample forgot that.I also tried using this and it stll doesnt work

cout<<static_cast<Boulder*>(l->getBoulderType()); // just wanted to see if it will show

What am I doing wrong here.
Topic archived. No new replies allowed.