The program does not run!

Discussion in 'Computer Science & Culture' started by Gunjan, Jul 27, 2003.

Thread Status:
Not open for further replies.
  1. Gunjan Registered Member

    Messages:
    12
    I have the following simple codes:

    Code:
    #include&ltiostream&gt
    using namespace std;
    
    class Code{
    	int id;
    public:
    	Code(){}
    	Code(int a){
    		id=a;
    	}
    	Code(Code &x)
    	{
    		id=x.id;
    	}
    	void display(){
    		cout&lt&ltid;
    	};
    
    
    	int main(){
    		Code A(100);
    		Code B(A);
    		Code C=A;
    		Code D;
    		D=A;
    
    		cout&lt&lt"id of A :";A.display();
    		cout&lt&lt"id of B :";B.display();
    		cout&lt&lt"id of C :";C.display();
    		cout&lt&lt"id of D :";D.display();
    		return 0;
    	}
    
    While compiling it gives an error ,the line number being ouside of the program.
    This is what exactly the error message is:
    Ex6.4.cpp(47) : fatal error C1071: unexpected end of file found
    Error executing cl.exe.

    Please help!
     
    Last edited: Jul 27, 2003
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. Stryder Keeper of "good" ideas. Valued Senior Member

    Messages:
    13,105
    I think it could be as simple as not having a Paired bracket "{}"
    Check your code:

    Code:
    class Code{
    ...
    But it doesn't close.
    
    Btw, most coding errors can be down to just this syntax error alone, it's not just found in C++ but also Perl, Java and Javascript.

    I usually debug by reading through the code and saying "Open" for { and "Close" for } aloud, if they don't pair up, then there is an error somewhere in the layout.
     
  4. Google AdSense Guest Advertisement



    to hide all adverts.
  5. Gunjan Registered Member

    Messages:
    12
    Yes,thanks,it was that!
     
  6. Google AdSense Guest Advertisement



    to hide all adverts.
  7. Rick Valued Senior Member

    Messages:
    3,336
    Code does close,but Last function defined is never closed...


    bye!
     
  8. cjard Registered Senior Member

    Messages:
    125
    eh? how can you say this?.. look at the indentation level.. but basically, each } closes the { before it.. everything was closed except the opening calss{ one..

    please tell me what bizarre notion of logic lead you to think that the last } you can see, applied to the class{ and not the main(){ ?
     
  9. Stryder Keeper of "good" ideas. Valued Senior Member

    Messages:
    13,105
    I'm guessing Zion's logic was that The Class Close closed at the bottom, and contained the rest of the programming.

    However the actual error pretty much states:
    Ex6.4.cpp(47) : fatal error C1071: unexpected end of file found
    Error executing cl.exe.

    Basically the "End" wasn't in the correct expected syntax.
     
Thread Status:
Not open for further replies.

Share This Page