Thread: Classess

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    36
    Rep Power
    12

    Classess


    OK, for those of you who read my earlier post, I have gotten this far on the code now. A pretty good amount I'd say. But I still get this list of errors.

    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(79) : error C2660: 'order' : function does not take 3 parameters
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(82) : error C2039: '==' : is not a member of 'Triangle'
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(5) : see declaration of 'Triangle'
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(83) : error C2255: '==' : a friend function can only be declared in a class
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(83) : error C2556: 'void __cdecl ==(const class Triangle &,const class Triangle &)' : overloaded function differs only by return type from 'bool __cdecl operator ==(const class Triangle
    &,const class Triangle &)'
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(8) : see declaration of '=='
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(84) : error C2662: 'get_side1' : cannot convert 'this' pointer from 'const class Triangle' to 'class Triangle &'
    Conversion loses qualifiers
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(84) : error C2662: 'get_side1' : cannot convert 'this' pointer from 'const class Triangle' to 'class Triangle &'
    Conversion loses qualifiers
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(84) : error C2662: 'get_side2' : cannot convert 'this' pointer from 'const class Triangle' to 'class Triangle &'
    Conversion loses qualifiers
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(84) : error C2662: 'get_side2' : cannot convert 'this' pointer from 'const class Triangle' to 'class Triangle &'
    Conversion loses qualifiers
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(84) : error C2662: 'get_side3' : cannot convert 'this' pointer from 'const class Triangle' to 'class Triangle &'
    Conversion loses qualifiers
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(88) : error C2255: '<<' : a friend function can only be declared in a class
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(88) : error C2556: 'void __cdecl operator <<(class ostream &,class Triangle &)' : overloaded function differs only by return type from 'class ostream &__cdecl operator <<(class ostream
    &,class Triangle &)'
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(9) : see declaration of '<<'
    Error executing cl.exe.

    Trangle.exe - 11 error(s), 0 warning(s)

    PHP Code:
    #include <iostream.h>
    #include <stdlib.h>

    class Triangle
    {
    public:
    friend TriangleCopy(Triangle triangle1);
    friend bool operator ==(const Triangletriangle1, const Triangletriangle2);
    friend ostreamoperator <<(ostreamoutsTrianglethe_triangle);

    Triangle(float side1float side2float side3);
    Triangle();

    void SetTriangle(float side1float side2float side3);

    bool IsEquilateral();
    bool IsIsosceles();
    bool IsScalene();

    bool IsRight();
    bool IsAcute();
    bool IsObtuse();
    float side_1side_2side_3;
    float get_side1();
    float get_side2();
    float get_side3();

    private:
        
    void swap(floatside_1floatside_2);
        
    void order();
    };

    void main()
    {
        
        
    cout << "display triangle 2: ";

    }
    void Triangle::swap(floatside_1floatside_2)
    {
    float temp side_1;
    side_1 side_2;
    side_2 temp;
    }

    void Triangle::order()
    {
    if (
    side_1 side_2)
    swap (side_1side_2);
    if (
    side_1 side_3)
    swap (side_1side_3);
    if (
    side_2 side_3)
    swap (side_2side_3);
    }

    float Triangle::get_side1()
    {
    return 
    side_1;
    }
    float Triangle::get_side2()
    {
    return 
    side_2;
    }
    float Triangle::get_side3()
    {
    return 
    side_3;
    }

    Triangle::Triangle(float side1float side2float side3)
    {
     
    SetTriangle(side1side2side3);
    }

    void Triangle::SetTriangle(float side1float side2float side3)
    {
     
    side_1 side1;
     
    side_2 side2;
     
    side_3 side3;
     
    order (side_1side_2side_3);
    }

    friend bool Triangle::operator==(const TriangleTriangle1, const TriangleTriangle2)
    {
     return(
    Triangle1.get_side1() == Triangle2.get_side1() && Triangle1.get_side2() == Triangle2.get_side2() && Triangle1.get_side3() == Triangle2.get_side3);
    }

    friend ostreamoperator <<(ostreamoutsTrianglethe_triangle)
    {
     return(
    outs << the_triangle.get_side1() << the_triangle.get_side2() << the_triangle.get_side3());
    }

    bool Triangle::IsEquilateral()
    {
     return(
    side_1 == side_2 && side_2 == side_3);
    }

    bool Triangle::IsIsosceles()
    {
     if(
    side_1 == side_2 && side_1 != side_3 && side_2 != side_3)
       return(
    true);
     if(
    side_2 == side_3 && side_2 != side_1 && side_3 != side_1)
       return(
    true);
     if(
    side_1 == side_3 && side_1 != side_2 && side_3 != side_2)
       return(
    true);
     return(
    false);
    }

    bool Triangle::IsScalene()
    {
     return(
    side_1 != side_2 && side_2 != side_3 && side_1 != side_3);
    }

    bool Triangle::IsRight()
    {
        return(
    side_3 side_3 == side_1 side_1 side_2 side_2);
    }
    bool Triangle::IsAcute()
    {
     return(
    side_1 side_2 side_3);

    bool Triangle::IsObtuse()
    {
        return (
    side_3 side_3 side_1 side_1 side_2 side_2);

    Could I please get some help here, thank ya.
  2. #2
  3. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    244
    One of the errors is actually quite self-explanatory:

    void Triangle::order()

    Your definition takes no arguments, yet you are passing three when you use it. I don't see any point on passing the three arguments.

    As for most of the rest, it is all related to one method. I can't get it to compile as a friend, I changed the declaration to this:

    bool operator==(const Triangle &triangle2) const;

    I changed the definition to this:

    Code:
    bool Triangle::operator==(const Triangle &Triangle2) const {
        return(side_1 == Triangle2.side_1 
                    && side_2 == Triangle2.side_2 
                    && side_3 == Triangle2.side_3);
        return true;
    }
    and it compiled. I can't see any problem with the way you had it, but this should work fine (at least until you make the side_* variables private like they should have been from the first).

    When I dropped the 'friend' from the definition of "friend ostream& operator <<(..." it compiled quite happily. I don't think (C++ gurus please correct) that you call anything a friend when you define it (unless, of course, you define it in the class where you declare it).

    These sorts of errors just require firing up google and then trying things until they work. Sometimes you can easily find the problem, sometimes it is real hard work, but that is what I did for you cuz I am such a great guy. Next time, try it on your own (the first error is a real no-brainer).

    NOTE: Disable smiles in all C++ code posts! I sure wish it was the default!

    My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
    Free code: http://sol-biotech.com/code/.
    Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
    Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
    LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    36
    Rep Power
    12
    I don't really know why there was a smiley face in my code. I guess I goofed up and put it there.
    Well, even when I remove freind from the declerations and definitions, I still get all those errors:

    PHP Code:
    #include <iostream.h>
    #include <stdlib.h>

    class Triangle
    {
    public:
        
    friend TriangleCopy(Triangle triangle1);
        
    bool operator ==(const Triangletriangle2) const;
        
    ostreamoperator <<(ostreamoutsTrianglethe_triangle);

        
    Triangle(float side1float side2float side3);
        
    Triangle();

        
    void SetTriangle(float side1float side2float side3);

        
    bool IsEquilateral();
        
    bool IsIsosceles();
        
    bool IsScalene();

        
    bool IsRight();
        
    bool IsAcute();
        
    bool IsObtuse();

        
    float side_1side_2side_3;
        
    float get_side1();
        
    float get_side2();
        
    float get_side3();

    private:
        
    void swap(floatside_1floatside_2);
        
    void order();
    };

    void main()
    {
        
    Triangle triangle1triangle2(6.06.06.0), triangle3(5.04.03.0), triangle4(6.04.04.0)
        
    cout << "display triangle 2: ";

    }

    Triangle::Triangle(float side1float side2float side3)
    {
        
    //SetTriangle(side1, side2, side3);
    }

    void Triangle::SetTriangle(float side1float side2float side3)
    {
        
    side_1 side1;
        
    side_2 side2;
        
    side_3 side3;
        
    order();
    }

    void Triangle::swap(floatside_1floatside_2)
    {
        
    float temp side_1;
        
    side_1 side_2;
        
    side_2 temp;
    }

    void Triangle::order()
    {
        if (
    side_1 side_2)
            
    swap (side_1side_2);
        if (
    side_1 side_3)
            
    swap (side_1side_3);
        if (
    side_2 side_3)
            
    swap (side_2side_3);
    }

    float Triangle::get_side1()
    {
        return 
    side_1;
    }
    float Triangle::get_side2()
    {
        return 
    side_2;
    }
    float Triangle::get_side3()
    {
        return 
    side_3;
    }

    bool Triangle::operator==(const TriangleTriangle2) const {
    {
        return(
    side_1Triangle2.side_1 && side_2 == Triangle2.side_2 && side_3 == Triangle2.side_3);
        return 
    true;
    }

    friend ostreamoperator <<(ostreamoutsTrianglethe_triangle)
    {
        return(
    outs << the_triangle.get_side1() << the_triangle.get_side2() << the_triangle.get_side3());
    }

    bool Triangle::IsEquilateral()
    {
        return(
    side_1 == side_2 && side_2 == side_3);
    }

    bool Triangle::IsIsosceles()
    {
        if(
    side_1 == side_2 && side_1 != side_3 && side_2 != side_3)
            return(
    true);
        If(
    side_2 == side_3 && side_2 != side_1 && side_3 != side_1)
            return(
    true);
        if(
    side_1 == side_3 && side_1 != side_2 && side_3 != side_2)
            return(
    true);
            return(
    false);
    }

    bool Triangle::IsScalene()
    {
        return(
    side_1 != side_2 && side_2 != side_3 && side_1 != side_3);
    }

    bool Triangle::IsRight()
    {
        return(
    side_3 side_3 == side_1 side_1 side_2 side_2);
    }
    bool Triangle::IsAcute()
    {
     return(
    side_1 side_2 side_3);

    bool Triangle::IsObtuse()
    {
        return (
    side_3 side_3 side_1 side_1 side_2 side_2);

    My errors still:
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(9) : error C2804: binary 'operator <<' has too many parameters
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(36) : error C2059: syntax error : 'constant'
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(41) : error C2228: left of '.Triangle' must have class/struct/union type
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(41) : error C2653: 'Triangle' : is not a class or namespace name
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(44) : warning C4508: 'Triangle' : function should return a value; 'void' return type assumed
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(46) : error C2653: 'Triangle' : is not a class or namespace name
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(54) : error C2653: 'Triangle' : is not a class or namespace name
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(56) : warning C4244: 'initializing' : conversion from 'int' to 'float', possible loss of data
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(61) : error C2653: 'Triangle' : is not a class or namespace name
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(62) : error C2373: 'order' : redefinition; different type modifiers
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(71) : error C2653: 'Triangle' : is not a class or namespace name
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(75) : error C2653: 'Triangle' : is not a class or namespace name
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(79) : error C2653: 'Triangle' : is not a class or namespace name
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(84) : error C2653: 'Triangle' : is not a class or namespace name
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(84) : error C2146: syntax error : missing ';' before identifier '=='
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(84) : error C2501: 'bool' : missing storage-class or type specifiers
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(84) : error C2377: 'bool' : redefinition; typedef cannot be overloaded with any other symbol
    c:\documents and settings\eli\my documents\trangle\trangail.cpp(0) : see declaration of 'bool'
    C:\Documents and Settings\Eli\My Documents\Trangle\Trangail.cpp(84) : fatal error C1004: unexpected end of file found
    Error executing cl.exe.
  6. #4
  7. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    244
    I hate to be rude, but you need to learn to interpret your compiler errors and handle this stuff yourself. Only make one change at a time, recompiling after each change, and not making another change untill you have resolved any errors you may have introduced. I have corrected your code so it compiles and runs, but I will leave it to you to make sense of my programming style and the (sometimes silly) mistakes you have made.

    Code:
    #include <iostream.h>
    #include <stdlib.h>
    
    class Triangle{
    public:
        friend TriangleCopy(Triangle triangle1);
        bool operator ==(const Triangle& triangle2) const;
        friend ostream& operator <<(ostream& outs, Triangle& the_triangle);
    
        Triangle(float side1, float side2, float side3);
        Triangle(){SetTriangle(3, 4, 5);};
    
        void SetTriangle(float side1, float side2, float side3);
    
        bool IsEquilateral();
        bool IsIsosceles();
    
        bool IsScalene(){return(side_1 != side_2 && side_2 != side_3 && side_1 != side_3);}
        bool IsRight(){return(side_3 * side_3 == side_1 * side_1 + side_2 * side_2);}
        bool IsAcute(){return(side_1 + side_2 < side_3);} 
        bool IsObtuse(){return (side_3 * side_3 > side_1 * side_1 + side_2 * side_2);}
    
        float side_1, side_2, side_3;
        float get_side1(){return side_1;};
        float get_side2(){return side_2;};
        float get_side3(){return side_3;};
    
    private:
        void swap(float& side_1, float& side_2);
        void order();
    };
    
    Triangle::Triangle(float side1, float side2, float side3){
        SetTriangle(side1, side2, side3);
    }
    
    void Triangle::SetTriangle(float side1, float side2, float side3){
        side_1 = side1;
        side_2 = side2;
        side_3 = side3;
        order();
    }
    
    void Triangle::swap(float& side_1, float& side_2){
        float temp = side_1;
        side_1 = side_2;
        side_2 = temp;
    }
    
    void Triangle::order(){
        if (side_1 > side_2)
            swap (side_1, side_2);
        if (side_1 > side_3)
            swap (side_1, side_3);
        if (side_2 > side_3)
            swap (side_2, side_3);
    }
    
    bool Triangle::operator==(const Triangle& Triangle2) const {
        return(side_1 == Triangle2.side_1 && side_2 == Triangle2.side_2 && side_3 == Triangle2.side_3);
    }
    
    ostream& operator <<(ostream& outs, Triangle& the_triangle) {
        outs << the_triangle.get_side1() << ":";
        outs << the_triangle.get_side2() << ":";
        outs << the_triangle.get_side3();
        return(outs);
    }
    
    bool Triangle::IsEquilateral(){
        return(side_1 == side_2 && side_2 == side_3);
    }
    
    bool Triangle::IsIsosceles(){
        if(side_1 == side_2 && side_1 != side_3 && side_2 != side_3)
            return(true);
        if(side_2 == side_3 && side_2 != side_1 && side_3 != side_1)
            return(true);
        if(side_1 == side_3 && side_1 != side_2 && side_3 != side_2)
            return(true);
            return(false);
    }
    
    int main(){
        Triangle triangle1;
        Triangle triangle2(6.2345, 6.0, 6.0);
        Triangle triangle3(5.0, 4.0, 3.0);
        Triangle triangle4(6.0, 4.0, 4.0);
    
        cout << "display triangle 1: " << triangle1 << endl;
        cout << "display triangle 2: " << triangle2 << endl;
        cout << "display triangle 3: " << triangle3 << endl;
        cout << "display triangle 4: " << triangle4 << endl;
    
        return 0;
    }
    Output:

    display triangle 1: 3:4:5
    display triangle 2: 6:6:6.2345
    display triangle 3: 3:4:5
    display triangle 4: 4:4:6

    My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
    Free code: http://sol-biotech.com/code/.
    Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
    Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
    LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw
  8. #5
  9. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,254
    Rep Power
    2222
    Originally posted by Gustavo
    I don't really know why there was a smiley face in my code. I guess I goofed up and put it there.
    No, that's one of the really irritating things about this forum's software. Certain combinations of colons, semicolons, and parentheses get interpreted as a smilie whether you meant for it to be one or not. Unfortunately, certain of these combinations occur frequently in C++ source code. Arggh!

    The secret is to always click on that checkbox below our edit box, "Disable Smilies in This Post". The other irritating thing is that we cannot set our profile to do that automatically, so we always have to remember to do it.
  10. #6
  11. No Profile Picture
    Hi, I'm Calvin
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    LosAngeles, SanDiego, Houston
    Posts
    50
    Rep Power
    12
    well, one mistake i saw (after mitakeet's corrections) is that inside of

    bool Triangle::IsIsosceles(){

    your third if brance has two return statements. i assume that the second one in there, "return false", is supposed to be outside of the last if branch.
  12. #7
  13. ASP.Net MVP
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Aug 2003
    Location
    WI
    Posts
    4,378
    Rep Power
    1511

    In defense of mitakeet


    He doesn't use braces with his if statements. You don't need to if there's only one line there. Good coding practices say use them anyway to avoid confusion, but I don't do it either, so what you gonna do about it? :D His last if statement only has the one line to return true, so the return false will only be executed if none of the conditions are met. Technially, I don't it's structured, but again, what you gonna do about it?
    Primary Forum: .Net Development
    Holy cow, I'm now an ASP.Net MVP!

    [Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers]

    http://twitter.com/jcoehoorn
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    36
    Rep Power
    12
    I have one more question, I am trying to get it to display if each triangle is equilateral, isosceles, or scalene. and right, obtuse, or acute. I can't figure out how to make it where they all don't display.

    PHP Code:
    int main(){
        
    Triangle triangle1;
        
    Triangle triangle2(6.06.06.0);
        
    Triangle triangle3(5.04.03.0);
        
    Triangle triangle4(6.04.04.0);

        
    cout << "display triangle 1: " << triangle1 << endl;
        if(
    bool IsIsosceles);
        {
            
    cout << "is iscoceles" << endl;
            
        }
        if(
    bool IsEquilateral);
        {
            
    cout << "is equilateral" << endl;
        }
             
    cout << "is scalene" << endl;
        
    bool IsRight;
            
    cout << "is right" << endl;
        
    bool IsObtuse;
            
    cout << "is obtuse" << endl;
            
    cout << "is acute" << endl;
        
    cout << "display triangle 2: " << triangle2 << endl;
        if (
    bool IsIsosceles true)
            
    cout << "is isosceles" << endl;
        
        if (
    bool IsEquilateral true)
            
    cout << "is equilateral" << endl;
        
            
    cout << "is scalene" << endl;
        if (
    bool IsRight true)
            
    cout << "is right" << endl;
        
        if (
    bool IsObtuse true)
            
    cout << "is obtuse" << endl;
        
            
    cout << "is acute" << endl;
        
    cout << "display triangle 3: " << triangle3 << endl;
        if (
    bool IsIsosceles true)
            
    cout << "is isosceles" << endl;
        
        if (
    bool IsEquilateral true)
            
    cout << "is equilateral" << endl;
        
            
    cout << "is scalene" << endl;
        if (
    bool IsRight true)
            
    cout << "is right" << endl;
        
        if (
    bool IsObtuse true)
            
    cout << "is obtuse" << endl;
        
            
    cout << "is acute" << endl;
        
    cout << "display triangle 4: " << triangle4 << endl;
            if (
    bool IsIsosceles true)
            
    cout << "is isosceles" << endl;
            else
                if (
    bool IsEquilateral true)
            
    cout << "is equilateral" << endl;
                else
            
    cout << "is scalene" << endl;if (bool IsRight true)
            
    cout << "is right" << endl;
        else
        if (
    bool IsObtuse true)
            
    cout << "is obtuse" << endl;
        else
            
    cout << "is acute" << endl;

        return 
    0;
    }

    and 
    of course I have everything declared or what not.  And do not need to display the messages within the functions.  With thisit just says that the triangle is equilateralisoscelesscalenerightobtuse, and acute
  16. #9
  17. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    244
    When you do "if (bool test)" you are getting the default value (or perhaps whatever is on the stack) for "test". Drop the 'bool' part and things may start to behave in an expected fashion. Of course, on second glance, you are testing variables that will not have any relation to your triangles, so you need to call a method from your triangle class. I will leave the rest up to you, just give it some thought.

    My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
    Free code: http://sol-biotech.com/code/.
    Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
    Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
    LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw
  18. #10
  19. ASP.Net MVP
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Aug 2003
    Location
    WI
    Posts
    4,378
    Rep Power
    1511
    yeah, the bool is definitely throwing your if statements off.
    if (bool IsIscoceles) creates a new boolean variable called IsIscoceles and returns true if the creation succeeded (it nearly always will, and if it doesn't the program will crash anyway because you're out of ram). Since it will always return true, you're going to execute the content of every one of your if statements.

    Also, you don't just say IsIscoles, etc. You must call it as a member of a class, like this: classinstance.methodname()
    Also notice the parentheses at the end-- it's a function, so use it like one.

    Finally, FYI, if you have a boolean function you don't need the == true. If the function returns true the condition is true, if it returns false the condition is false.
    Primary Forum: .Net Development
    Holy cow, I'm now an ASP.Net MVP!

    [Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers]

    http://twitter.com/jcoehoorn

IMN logo majestic logo threadwatch logo seochat tools logo