Note that there are some explanatory texts on larger screens.

plurals
  1. POError in C++ : redefinition of class constructor
    primarykey
    data
    text
    <p>I've encountered these two error when trying to compile..</p> <p>anyone knows whats wrong ?</p> <p>Was thinking maybe I #include the wrong header file ? the sample of the codes and error as per following: </p> <p>Error:</p> <pre><code>Square.cpp:8: error: redefinition of ‘Square::Square(bool, Point*, std::string, int)’ Square.h:21: error: ‘Square::Square(bool, Point*, std::string, int)’ previously defined here Square.cpp: In member function ‘Point Square::getCoord()’: Square.cpp:22: error: expected primary-expression before ‘]’ token Square.cpp: In member function ‘void Square::setCoord(Point*)’: Square.cpp:32: error: expected primary-expression before ‘]’ token Square.cpp:32: error: expected primary-expression before ‘]’ token </code></pre> <p>cpp file</p> <pre><code>#include "Square.h"` #include &lt;cmath&gt; using namespace std; Square::Square(bool containsWarpSpace, Point coord[], string shapeName, int vertPoint):ShapeTwoD(shapeName, containsWarpSpace) { vertPoint = vertPoint; coord[] = coord[]; } int Square::getVertPoint() { return vertPoint; } Point Square::getCoord() { return coord[]; } void Square::setVertPoint(int verticleP) { vertPoint = verticleP; } void Square::setCoord(Point coord[]) { coord[] = coord[]; } </code></pre> <p>header:</p> <pre><code>#include "ShapeTwoD.h" class Square : public ShapeTwoD { private: int vertPoint; Point coord[]; public: //Accessor int getVertPoint(); Point getCoord(); //Mutator void setVertPoint(int vertP); void setCoord(Point coord[]); //virtual member virtual double computeArea(Point x, Point y); Square(bool containsWarpSpace, Point coord[], std::string shapeName = "Square", int vertPoint = 4):ShapeTwoD(shapeName, containsWarpSpace){} }; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload