Why wont this compile?

I am making a simple program to demonstrate classes with triangles, and for some reason, what I have so far wont compile.
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
#include <iostream>
#include <cmath>

using namespace std;

class triangle
{
   float area;
   float a;
   float b;
   float c;
public:
       triangle(double x,double y,double z)
       {
                       if (x=0)
                       {
                               a = sqrt((c*c)-(b*b));
                               b = y;
                               c = z;
                       }
                       if (y=0)
                       {
                               a = x;
                               b = sqrt((c*c)-(a*a));
                               c = z;
                       }
                       if (z=0)
                       {
                               a = x;
                               b = y;
                               c = sqrt((a*a)-(b*b));
                       }
       }
}
       
int main(int argc, char *argv[])
{
    system("PAUSE");
    return 0;
}

what's wrong with my syntax?
You forgot the semicolon after the class definition (line 34).

Notice that, as it is, your constructor won't work. You're assigning (=) the values instead of comparing them (==) in the if statements.

Also, why are you storing floats and asking for doubles?
Last edited on
Topic archived. No new replies allowed.