问题描述
我正在从以下C ++网站学习C ++,这个网站有一些非常好的小例子。对于第二个Fraction示例,它有五个
文件:
Main.cpp
Fraction.cpp
Fraction.h
msoftcon.cpp
msoftcon.h
,,,,,
A分数类能够加,减,乘,
除以并显示分数的各种统计数据。
,,,,,,,,, ,,,,
当我编译它们时,MSVC 6 ++编译器说:
错误C2653:''Fraction'':是不是类或命名空间名称
如果我将Fraction.h与源文件类别下的.cpp放在一起。
如果我把Fraction.h放在Header Files下类别,编译器问题
找到.h文件。我也在项目菜单中尝试过设置
但没有成功。我是MSVC和C ++的新手,你能帮我设置
吗?非常感谢。
Hi,
I am learning C++ from the following C++ website, which has some very
good small examples. For the second Fraction example, which has five
files:
Main.cpp
Fraction.cpp
Fraction.h
msoftcon.cpp
msoftcon.h
,,,,,
A Fraction class that has the ability to add, subtract, multiply,
divide and show various statistics of the fraction.
http://www.cplusplus.com/src/
,,,,,,,,,,,,,
When I compile them, MSVC 6++ compiler says:
error C2653: ''Fraction'' : is not a class or namespace name
if I put Fraction.h with the .cpp under Source Files category.
If I put Fraction.h under Header Files category, the compiler cannod
find the .h file. I have also tried Settings in the Project menu
without success. I am new to MSVC and C++, could you help me the
settings? Thank you very much.
推荐答案
你#include" Fraction.h"在Main.cpp和Fraction.cpp?
Did you #include "Fraction.h" in Main.cpp and Fraction.cpp?
你#include" Fraction.h"在Main.cpp和Fraction.cpp? - Masquer le texte desmessagesprécédents -
- Afficher le texte desmessagesprécédents -
Did you #include "Fraction.h" in Main.cpp and Fraction.cpp?- Masquer le texte des messages précédents -
- Afficher le texte des messages précédents -
在Main.cpp中,包含了Fraction.h。
在Fraction.h末尾有:
......... ..
#include" Fraction.cpp"
#endif
...........
Fraction.cpp似乎是类Fraction
函数声明的一部分。我不知道如何解决这个问题。谢谢。
In Main.cpp, Fraction.h is included.
At the end of Fraction.h, there is:
...........
#include "Fraction.cpp"
#endif
...........
Fraction.cpp seems to be part of declaration of class Fraction
function. I don''t know how to solve this. Thanks.
您必须在源文件中包含标头。你的书应该
解释一下。
Brian
You have to include the header in the source file. Your book should
explain this.
Brian
这篇关于为什么MSVC 6 ++找不到.h文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!