Unexpected end-of-file found
Oct 23, 2011 at 2:00pm UTC
Hey, I'm just starting and I am using Visual Studio 2010 as a compiler. I get the error: Unexpected end-of-file found. Here is the code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#include "stdafx.h"
#include <iostream>
using namespace std;
class MyTut {
int main()
{
MyTut tut;
tut.make();
}
void make() {
cout << "Hello" ;
cout << "Object Made" ;
cin.get();
}
}
The error is at line 31, but the program only has 30 lines. I realize that this is probably some nooby mistake, or something that I don't realize I'm missing, but please don't make fun of me.
Oct 23, 2011 at 2:03pm UTC
C++ does not put the main function inside a class. This looks like you're trying to write Java using C++ syntax.
Note also that C++ classes require a semi-colon at the end of their definition -
http://cplusplus.com/doc/tutorial/classes/
Last edited on Oct 23, 2011 at 2:05pm UTC
Oct 23, 2011 at 3:04pm UTC
Nevermind, I got it :)
Last edited on Oct 23, 2011 at 3:30pm UTC
Topic archived. No new replies allowed.