0

C++ Constructor Implementation Error

I have 2 class

Map2D(parent) & Map3D(child)

So this is what happen...

class Map3D : public Map2D
{
private:
int z;

public:
Map3D();
Map3D(int,int,int);
int getZ();

}

And below is my Map2D

class Map2D
{

friend ifstream& operator>>(ifstream&, Map2D&);

protected:
int x;
int y;

public:
Map2D();
Map2D(int,int);

};

Map2D::Map2D()
{
x=0;
y=0;
}

Map2D::Map2D(int xIn,int yIn)
{
x = xIn;
y = yIn;
}

The problem now is i try to implement Map3D but got issue.. which what i try is below

Back on Map3D.cpp

Map3D::Map3D()
{
x=0;
y=0;
z=0;
}

Map3D::Map3D(int xIn,int yIn,int zIn)
{
x=xIn;
y=yIn;
z=zIn;
}

map3d.cpp:18:1: error: extra qualification ‘map3D::’ on member ‘map3D’ [-fpermissive]
map3d.cpp:18:1: error: ‘map3D::map3D()’ cannot be overloaded
map3d.cpp:14:1: error: with ‘map3D::map3D()’
map3d.cpp:25:1: error: extra qualification ‘map3D::’ on member ‘map3D’ [-fpermissive]
map3d.cpp:25:1: error: ‘map3D::map3D(int, int, int)’ cannot be overloaded
map3d.cpp:15:1: error: with ‘map3D::map3D(int, int, int)’

What should i change to make my implementation correct. Thanks for all help.

2
  • Unfortunately the code you pasted here doesn't correspond to the error message you gave us (map3D vs Map3D) so it's going to be hard to diagnose. Commented Nov 14, 2012 at 16:59
  • @MarkB It's amazing, you think cutting and pasting code would be easier. Commented Nov 14, 2012 at 17:00

1 Answer 1

4

Looks like a missing semi-colon at the end of the Map3D declaration

class Map3D : public Map2D
{
private:
int z;

public:
Map3D();
Map3D(int,int,int);
int getZ();

}; // SEMI-COLON HERE!!!!
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.