Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ error: 'Line2' has not been declared
    text
    copied!<blockquote> <p>C:\CodeBlocks\kool\praks2\src..\include\circle2.h|8|error: 'Line2' does not name a type| C:\CodeBlocks\kool\praks2\src..\include\circle2.h|17|error: 'Line2' has not been declared| ||=== Build finished: 2 errors, 0 warnings ===|</p> </blockquote> <p>circle2.h : </p> <pre><code>#ifndef CIRCLE2_H #define CIRCLE2_H #include "geometry.h" class Circle2 { public: Vector2 p1; float r; Circle2(); Circle2(Vector2 np1, float nr); float circumference(); float area(); bool contains(Vector2 v); bool contains(Line2 l); // error is here. void scale(float factor); friend ostream&amp; operator &lt;&lt;(ostream&amp; out, const Circle2&amp; cir); }; #endif // CIRCLE2_H </code></pre> <p>circle.cpp:</p> <pre><code>bool Circle2::contains(Line2 l) { return 0; } </code></pre> <p>geometry.h:</p> <pre><code>#ifndef GEOMETRY_H #define GEOMETRY_H // These are needed to use the functions in our library #include &lt;iostream&gt; using namespace std; // Include own headers // NB! Add your own headers here! #include "vector2.h" #include "line2.h" #include "circle2.h" #endif // GEOMETRY_H </code></pre> <p>This is circle2.cpp:</p> <pre><code>#include "../include/circle2.h" #include &lt;math.h&gt; Circle2::Circle2() { p1 = Vector2(); r = 0; } Circle2::Circle2(Vector2 np1, float nr) { p1 = np1; r = nr; } float Circle2::circumference() { return 2 * r * M_PI; } float Circle2::area() { return pow(r, 2) * M_PI; } bool Circle2::contains(Vector2 v) { if(p1.distanceFrom(v) &lt;= r) return 1; return 0; } bool Circle2::contains(Line2 l) { return 0; } void Circle2::scale(float factor) { r *= factor; } ostream&amp; operator&lt;&lt;(ostream&amp; out, const Circle2&amp; cir) { out &lt;&lt; "(" &lt;&lt; cir.p1 &lt;&lt; ", " &lt;&lt; cir.r &lt;&lt; ")"; return out; } </code></pre> <p>line2.cpp:</p> <pre><code> #include "../include/line2.h" #include &lt;math.h&gt; Line2::Line2() { p1 = Vector2(); p2 = Vector2(); } Line2::Line2(Vector2 np1, Vector2 np2) { p1 = np1; p2 = np2; } float Line2::length() { return p1.distanceFrom(p2); } ostream&amp; operator&lt;&lt;(ostream&amp; out, const Line2&amp; line) { out &lt;&lt; "(" &lt;&lt; line.p1 &lt;&lt; " - " &lt;&lt; line.p2 &lt;&lt; ")"; return out; } </code></pre> <p>line2.h:</p> <pre><code> #ifndef LINE2_H #define LINE2_H #include "geometry.h" class Line2 { public: Vector2 p1; Vector2 p2; Line2(); Line2(Vector2 np1, Vector2 np2); float length(); friend ostream&amp; operator &lt;&lt;(ostream&amp; out, const Line2&amp; line); }; #endif // LINE2_H </code></pre>
 

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