i need plenty help!!! with some C++

Discussion in 'C++' started by Resh, May 6, 2007.

  1. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    It was used to initialize the graphics drivers. Apparently the version was Borland's C/C++ 4.5. Whether or not that set of software is compatible withthe OP's platform is subject to question.
     
  2. Resh

    Resh New Member

    Joined:
    May 6, 2007
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Well i am using is windows ME and the software is Microsoft Visual C++ 6.0 and unfortunately i dont understand some of what you said but thank you nevertheless
     
  3. Resh

    Resh New Member

    Joined:
    May 6, 2007
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    ok well when i remove the the conio.h, time.h and math.h from the program and insert the windows.h the errors that are coming up are sin and cos are undeclared identifiers what should i do about that??
     
  4. aVague

    aVague New Member

    Joined:
    May 2, 2007
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    forex
    brrrrrrrr,
    sin and cos have prototypes in math.h , in windows.h mb too , you can search there
    that ' s unimportant , you can include all libraly , and there ll be no errors
     
  5. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    Okay, I'm going to recommend that you #include <cmath>. I have VC++6.0 also, and it is part of the include files. If you need time, use ctime. The reason for making the change is so that names that are part of the standard library live in a namespace called std. This reduces the probability of your choosing a label or identifier that clashes with the standard library names.

    The drawback (though slight) is that you need to fully qualify names like "cout" as "std::cout". The alternative is to add a statement below the includes like: "using std::cout;" You can then use just "cout" (however, don't name something of your own, cout). You may see a recommendation to add a statement like "using namespace std;". This brings ALL the namespace in, and destroys the purpose of having the namespace in the first place. You can get away with it for examples and trivial programs, but it's better not to get into the habit.

    It's unfortunate about the VC++ 6.0. It was actually written before the standard was adopted and is non-compliant in many respects, some important. I would suggest that you visit Microsoft and check out the requirements for VC2005 Express Edition. It's free, but I'm not sure if ME and your system's memory will be enough to handle it. If so, you will get a fairly compliant compiler. The debugger is every bit as good as the one in VC++ 6.0, one of the best available.

    At any rate, since I have an old VC++ 6.0, I will be able to replicate any problems you encounter and suggest solutions.

    If you absolutely require screen control such as that which was afforded by conio.h (and the conio.h that comes with Dev-Cpp as well), then I have Windows API specific code that can provide that. It just tosses portability to the winds. One does it in *nix with curses. That's a library, not what you say when you use it.
     
  6. Resh

    Resh New Member

    Joined:
    May 6, 2007
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    the #include<cmath> and #include<ctime> worked great to remove the errors for sin and cos however by chance is there one that i can include to remove moveto, lineto, setcolor, closegraph and initgraph where do those five live?????
     
  7. Resh

    Resh New Member

    Joined:
    May 6, 2007
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    also i dont quite understand how to input the "using std::cout;" becuase it removes the error LNK2001 but then it is creating errors on how i input it so that is giving me problems.
     
  8. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    You do not have moveto, lineto, etc. You cannot use those. Where did you get this file? Please post the entirety of the code, as it now stands. That way, I can see the cout also.
     
  9. Resh

    Resh New Member

    Joined:
    May 6, 2007
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    This is the code as it stands now but the 6 errors still exist and refuse to be removed


    Code:
    #include<cmath>
    #include<stdlib.h>
    #include<windows.h>
    #include<ctime>
    #include<conio.h>
         
    
    // The standard Borland 16 colors
    #define MAXCOLORS       15;
    enum colors { BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY, DARKGRAY,
                  LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE };
    
    // Drawing Functions
    void initgraph( int *graphdriver, int *graphmode, char *pathtodriver);
    void lineto (int x,int y);
    
    // Miscellaneous Functions
    void moveto( int x,int y );
    void setcolor( int color );
    
    // The various graphics drivers
    enum graphics_drivers { DETECT, CGA, MCGA, EGA, EGA64, EGAMONO, IBM8514, HERCMONO,
                            ATT400, VGA, PC3270 };
    
    // Various modes for each graphics driver
    enum graphics_modes { CGAC0, CGAC1, CGAC2, CGAC3, CGAHI, 
                          MCGAC0 = 0, MCGAC1, MCGAC2, MCGAC3, MCGAMED, MCGAHI,
                          EGALO = 0, EGAHI,
                          EGA64LO = 0, EGA64HI,
                          EGAMONOHI = 3,
                          HERCMONOHI = 0,
                          ATT400C0 = 0, ATT400C1, ATT400C2, ATT400C3, ATT400MED, ATT400HI,
                          VGALO = 0, VGAMED, VGAHI,
                          PC3270HI = 0,
                          IBM8514LO = 0, IBM8514HI };
    
    // Constants for closegraph
    #define CURRENT_WINDOW -1
    #define ALL_WINDOWS -2
    #define NO_CURRENT_WINDOW -3
    
    // Window Creation / Graphics Manipulation
    void closegraph( int wid=ALL_WINDOWS );
    
    // Miscellaneous Functions
    void moveto( int x,int y );
    void setcolor( int color );
    
    // User Interaction
    int getch( );
    int kbhit( );
    
    double sin (double);
    double cos (double);
    
    const int X0=320;
    const int Y0=240;
    const double PI=3.14159;
    const int NUME=30;
    const int DENOM=100;
    const int NUMBER=7;
    const double RAD=3.0;
    const double DELTHETA=0.1;
    const int SEGS=60;
    const int REDUX=3;
    const int MIN=1;
    
    
    class cluster
    {
    public:
    	void display(int size,int x,int y);
    };
    
    class tendril
    {
    public:
    	void display(int size,double theta,int x,int y);
    };
    
    void cluster::display(int size,int x,int y)
    {
    	if(kbhit())
    		exit(0);
    	for(int i=0;i<NUMBER;i++)
    	{
    		double theta=i*2*PI/NUMBER;
    		moveto(x,y);
    		tendril t;
    		t.display(size,theta,x,y);
    	}
    }
    void tendril::display(int size,double theta,int x,int y)
    {
    	for(int j=0;j<size;j++)
    	{
    		double chng=rand();
    		 if ((chng < NUME) ?-1:1)
    		 {
    			double theta=theta+chng*DELTHETA;
    			double x=x+RAD*sin(theta);
    			double y=y+RAD*cos(theta);
    		 }
    		if(size<4)setcolor(RED);
    			else if(size<13)setcolor(GREEN);
    		else if(size<40)setcolor(LIGHTGREEN);
    		else setcolor(YELLOW);
    		lineto(x,y);
    	}
    
    	if(size>MIN)
    	{
    		cluster c;
    		int newsize=size/REDUX;
    		c.display(newsize,x,y);
    	}
    }
    void main()
    {
    	int driver,mode;
    	driver=VGA;
    	mode=VGAHI;
    	initgraph(&driver,&mode,"\\bc45\\bgi");
    	rand();
    
    	int x=X0,y=Y0;
    	int size=SEGS;
    	cluster c;
    	c.display(size,x,y);
    	getch();
    	closegraph();
    }
     
  10. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    The only way you're going to get that to work is to get your hands on the libraries that shipped with Borland's C++ 4.5 or rewrite the screen controls with the Windows console API.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice