Help Me

This is a discussion on Help Me within the C++ Programming forums, part of the General Programming Boards category; HELP!!! Plz fix my code someone. I'm a noob to C++ and cant figure out why im getting errors. Im ...

  1. #1
    RPW
    RPW is offline
    Registered User
    Join Date
    Dec 2002
    Posts
    43

    Help Me

    HELP!!!
    Plz fix my code someone. I'm a noob to C++ and cant figure out why im getting errors. Im using BloodShed.


    Code:
    #include <winbgim.h> //I got this online. If u need it ask me.
    class Point
    {
    public:
    Point(int x, int y, int z): X(x), Y(y), Z(z){}
    ~Point(){}
    long int SetX(int x){X=x;}
    long int SetY(int y){Y=y;}
    long int SetZ(int z){Z=z;}
    long int GetX(){return X;}
    long int GetY(){return Y;}
    long int GetZ(){return Z;}
    long int NewX();
    long int NewY();
    private:
    int X,Y,Eye,Size,Scale,Z,OldX,OldY,MaxX,MaxY;
    };
    
    long Point::NewY()
    {
    MaxY=600;
    OldY=Y;
    Eye =MaxY/6;
    int Size=1-Eye/Z;
    Y=OldY-Size*(OldY-Eye);
    return Y;
    }
    
    long Point::NewX()
    {
    MaxX=600;
    OldX=X;
    Scale=MaxX/6;
    Size=1-Scale/Z;
    X=OldX-Size*OldX;
    return X;
    }
    
    class Line
    {
    public:
    Line(int x,int y,int z,int a,int b,int w):X(x),Y(y),Z(z),A(a),B(b),W(w){}
    ~Line(){}
    void Draw();
    Point P1(int x,int y,int z){x=X;y=Y;z=Z;}
    Point P2(int a,int b,int w){a=A;b=B;w=W;}
    private:
    int A;
    int B;
    int X;
    int Y;
    int Z;
    int W;
    
    };
    
    void Line:raw()
    {
    P1.NewX;
    P1.NewY;
    P2.NewX;
    P2.NewY;
    moveto(P1.GetX,P1.GetY);
    lineto(P2.GetX,P2.GetY);
    }


    WHATS WRONG



    Code tags added by Hammer

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    >void Line:raw()

    Should be void Line::raw().

    >Point P1(int x,int y,int z){x=X;y=Y;z=Z;}

    This is wrong. If you want P1 to be initialised, you should do this the same way you initialised the other variables in your class.

    >P1.NewX;

    NewX is a function, so it should be

    P1.NewX();
    Last edited by Shiro; 12-31-2002 at 03:25 AM.

  3. #3
    RPW
    RPW is offline
    Registered User
    Join Date
    Dec 2002
    Posts
    43
    THANKS A BUNCH!!! I'll try it.

  4. #4
    RPW
    RPW is offline
    Registered User
    Join Date
    Dec 2002
    Posts
    43

    Still not working!!!

    It still doesn't work:

    //This is my own 3d header
    #include <winbgim.h>
    class Point
    {
    public:
    Point(int x, int y, int z): X(x), Y(y), Z(z){}
    ~Point(){}
    long int SetX(int x){X=x;}
    long int SetY(int y){Y=y;}
    long int SetZ(int z){Z=z;}
    long int GetX(){return X;}
    long int GetY(){return Y;}
    long int GetZ(){return Z;}
    long int NewX();
    long int NewY();
    private:
    int X,Y,Eye,Size,Scale,Z,OldX,OldY,MaxX,MaxY;
    };

    long Point::NewY()
    {
    MaxY=600;
    OldY=Y;
    Eye =MaxY/6;
    int Size=1-Eye/Z;
    Y=OldY-Size*(OldY-Eye);
    return Y;
    }

    long Point::NewX()
    {
    MaxX=600;
    OldX=X;
    Scale=MaxX/6;
    Size=1-Scale/Z;
    X=OldX-Size*OldX;
    return X;
    }

    class Line
    {
    public:
    Line(int x,int y,int z,int a,int b,int w):X(x),Y(y),Z(z),A(a),B(b),W(w){}
    ~Line(){}
    void Draw();
    Point P1(int x,int y,int z){x(X);y(Y);z(Z);}
    Point P2(int a,int b,int w){a(A);b(B);w(W);}
    private:
    int A;
    int B;
    int X;
    int Y;
    int Z;
    int W;

    };

    void Line:raw() //Thats A : D BUT IT SHOWS AS SMILEY
    {
    P1.NewX();
    P1.NewY();
    P2.NewX();
    P2.NewY();
    moveto(P1.GetX,P1.GetY);
    lineto(P2.GetX,P2.GetY);
    } //End of 3d.h






    This is the Test program iv'e made:

    #include <IOSTREAM>
    #include <3d.h> //File above

    int main()
    {
    initwindow(600,600);
    Line A(20,20,1,30,40,5);
    closegraph();
    return 0;
    } //End


    I get the following errors:



    2 c:\mydocu~1\ryan_p~1.net\3d-cal~1\box.cpp
    C:\DEV-C_~1\INCLUDE\3d.h: In method `class Point Line::P1(int, int, int)':

    45 c:\dev-c_~1\include\3d.h
    `x' cannot be used as a function

    45 c:\dev-c_~1\include\3d.h
    `y' cannot be used as a function

    45 c:\dev-c_~1\include\3d.h
    `z' cannot be used as a function

    46 c:\dev-c_~1\include\3d.h
    `a' cannot be used as a function

    46 c:\dev-c_~1\include\3d.h
    `b' cannot be used as a function

    46 c:\dev-c_~1\include\3d.h
    `w' cannot be used as a function

    59 c:\dev-c_~1\include\3d.h
    sorry, not implemented: `overload' not supported by dump_expr

    59 c:\dev-c_~1\include\3d.h
    request for member `NewX' in `{error}', which is of non-aggregate type `{unknown type}'

    60 c:\dev-c_~1\include\3d.h
    sorry, not implemented: `overload' not supported by dump_expr

    60 c:\dev-c_~1\include\3d.h
    request for member `NewY' in `{error}', which is of non-aggregate type `{unknown type}'

    61 c:\dev-c_~1\include\3d.h
    sorry, not implemented: `overload' not supported by dump_expr

    61 c:\dev-c_~1\include\3d.h
    request for member `NewX' in `{error}', which is of non-aggregate type `{unknown type}'

    62 c:\dev-c_~1\include\3d.h
    sorry, not implemented: `overload' not supported by dump_expr

    62 c:\dev-c_~1\include\3d.h
    request for member `NewY' in `{error}', which is of non-aggregate type `{unknown type}'

    63 c:\dev-c_~1\include\3d.h
    sorry, not implemented: `overload' not supported by dump_expr

    63 c:\dev-c_~1\include\3d.h
    request for member `GetX' in `{error}', which is of non-aggregate type `{unknown type}'

    63 c:\dev-c_~1\include\3d.h
    sorry, not implemented: `overload' not supported by dump_expr

    63 c:\dev-c_~1\include\3d.h
    request for member `GetY' in `{error}', which is of non-aggregate type `{unknown type}'

    64 c:\dev-c_~1\include\3d.h
    sorry, not implemented: `overload' not supported by dump_expr

    64 c:\dev-c_~1\include\3d.h
    request for member `GetX' in `{error}', which is of non-aggregate type `{unknown type}'

    64 c:\dev-c_~1\include\3d.h
    sorry, not implemented: `overload' not supported by dump_expr

    64 c:\dev-c_~1\include\3d.h
    request for member `GetY' in `{error}', which is of non-aggregate type `{unknown type}'



    HELP ME!!!

    Last edited by RPW; 12-31-2002 at 01:17 PM.

  5. #5
    RPW
    RPW is offline
    Registered User
    Join Date
    Dec 2002
    Posts
    43
    When i do that i get this error:

    Line: Unit: Message:
    45 c:\dev-c_~1\include\3d.h only constructors take base
    initializers
    Im confused


    Im going to attach both files to this so someone can try to get it to work...
    Attached Files Attached Files
    • File Type: h 3d.h (1,008 Bytes, 74 views)

  6. #6
    RPW
    RPW is offline
    Registered User
    Join Date
    Dec 2002
    Posts
    43
    here's the test file
    Attached Files Attached Files

  7. #7
    booyakasha
    Join Date
    Nov 2002
    Posts
    208
    I think you should study more and then start this project over.

    Or just go through each line and spend sometime thinking it through and making sure it does exactly what you intended.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21