2013-04-26 68 views
0

我还是新编程,我开始了一个草案项目,并将代码复制到另一个项目中,但是当我尝试调试时,我得到了这个错误消息,我不知道最近发生了什么。任何人都可以帮助我吗?C++编译器错误信息

// this is my code 

    #include "Questions.h" 

    #include <iostream> 
    #include <fstream> 

    using namespace std;  

    int main(void) 
    { 
     ofstream myfile; 
     myfile.open ("Questions.txt"); 
     myfile << "Writing this to a file.\n"; 
     myfile.close(); 
     return 0;   
    } 

错误说

错误C1075:文件末尾的左大括号 '{' 在 @ questions.cpp(10)被匹配

+6

该错误可能出现在Questions.h中 – 2013-04-26 02:21:46

+1

您的代码编译并在[ideone](http://ideone.com/qCsJA5)上正常工作。创建一个新文件,将代码复制粘贴到其中,然后重试。 – dasblinkenlight 2013-04-26 02:23:00

回答

2

之前该错误消息是自我解释。

看看questions.cpp中的代码,主函数在哪里结束? (请记住,头文件是逐字包含的,所以请确保头文件具有相同数量的{'s'),并且它们不是#ifdef'ed。)注释由Victor Sand提供,dasblinkenlight和Hot Licks都很好。

你现在的代码根本不使用Questions.h(现在你已经注释了大部分实现),所以请尝试包括out和then测试的注释。如果通过,问题出在Questions.h中。

+0

感谢您的帮助 – 2013-04-26 13:40:58

1

你的问题是不是更容易从Questions.h

未来如果在检查结束该文件,你会更可能看不到}。

+0

感谢您的帮助 – 2013-04-26 13:41:42