user1578897
user1578897

Reputation: 179

C++ Constructor Implementation Error

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.

Upvotes: 0

Views: 1142

Answers (1)

john
john

Reputation: 8027

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!!!!

Upvotes: 4

Related Questions