This is probably something simple but...

This is a discussion on This is probably something simple but... within the C++ Programming forums, part of the General Programming Boards category; I am trying to do a program where it draws a green square within a SimpleWindow. The square has to ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    72

    This is probably something simple but...

    I am trying to do a program where it draws a green square within a SimpleWindow. The square has to have 1.5 cm sides and be centered 3.5 cm from the left edge and 2.5 from the top edge of the window. I am required to do this with a square.h class that I have included with this post.. I am getting the following message when attempting to compile it (with VC++ 6.0):

    c:\program files\microsoft visual studio\myprojects\ex_712a\ex_712a.cpp(27) : fatal error C1010: unexpected end of file while looking for precompiled header directive
    Error executing cl.exe.

    ex_712a.exe - 1 error(s), 0 warning(s)


    Here is the code for my main source and my square class..

    main source:

    Code:
    #include <iostream>
    #include "square.h"
    
    
    using namespace std;
    
    int ApiMain() {
    	SimpleWindow Test;
       	Test.Open();
    	Square GreenSquare(Test);
    	GreenSquare.SetColor(Green);
    	GreenSquare.SetPosition(3.5,2.5);
    	GreenSquare.SetSize(1.5);
    	
    	GreenSquare.Draw();
        cout << "Type a character followed by a\n" << "return to remove the display and exit" << endl;
    	char AnyChar;
    	cin >> AnyChar;
    	Test.Close();
    	return 0;
    }
    Square.h (class):

    Code:
    #ifndef SQUARE_H
    #define SQUARE_H
    #include "ezwin.h"
    
    
    class Square {
    	public:
    		Square(SimpleWindow &W);
    		void Draw();
    		void SetColor(const color &Color);
    		void SetPosition(float XCoord, float YCoord);
    		void SetSize(float Length);
    	private:
    		color Color;
    		float XCenter;
    		float YCenter;
    		float SideLength;
    		SimpleWindow &Window;
    };
    #endif
    I did also have the following enum in the square.h, but the compiler was complaining about it, so I thought that it might not be necessary..

    enum color {Red, Green, Blue, Yellow, Cyan, Magenta};

    Any help or pointers that someone may have would be great. Thanks!!

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    #include "square.h"

    What's the name of the file with

    Square.h (class):

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    72

    The file name is..

    The file name is simply square.h and it resides in the same directory/folder as my main .cpp file. Maybe that's part of the problem, should I have put that square.h file in my include directory instead?

  4. #4
    Registered User dragunsflame's Avatar
    Join Date
    Jan 2003
    Posts
    8
    Did you add the header file to the project or is that even required?

    I'm not sure though...I don't use MSVC++ much.

  5. #5
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109

    Re: The file name is..

    Originally posted by hpy_gilmore8
    The file name is simply square.h and it resides in the same directory/folder as my main .cpp file. Maybe that's part of the problem, should I have put that square.h file in my include directory instead?
    no, leave it with main, especially since you are including it with " ". plus, i don't think it would work if you add it to compiler include directory.

    dragunsflame, you shouldn't add a header to a project, but you should add .cpp if it isn't #included at the bottom of the header if it is templated.

    is ezwin.h in the same folder as main and square.h ? also include ezwin.cpp, if not done so.

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    72
    ezwin.h is in a different folder than the square.h is. I have the square.h in its own special folder that I made for the project and the ezwin.h is in the"INCLUDE" folder with the rest of the other header files. Could that be what is making the compiler complain? Thanks!

  7. #7
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    ezwin.h is included with " ". so it should be in the same folder as square.h . try placing ezwin.h in the same folder as square.h, or tell it to include it with it being in a different folder.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. creating very simple text editor using c
    By if13121 in forum C Programming
    Replies: 9
    Last Post: 10-19-2010, 06:26 PM
  2. Simple message encryption
    By Vicious in forum C++ Programming
    Replies: 10
    Last Post: 11-07-2004, 11:48 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  4. Simple simple program
    By Ryback in forum C++ Programming
    Replies: 10
    Last Post: 09-09-2004, 06:48 AM
  5. Need help with simple DAQ program
    By canada-paul in forum C++ Programming
    Replies: 12
    Last Post: 03-15-2002, 08:52 AM

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