为什么MSVC 6 ++找不到.h文件? [英] Why MSVC 6++ cannot find the .h file?

查看:86
本文介绍了为什么MSVC 6 ++找不到.h文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在从以下C ++网站学习C ++,这个网站有一些非常好的小例子。对于第二个Fraction示例,它有五个

文件:


Main.cpp

Fraction.cpp

Fraction.h

msoftcon.cpp

msoftcon.h

,,,,,

A分数类能够加,减,乘,
除以并显示分数的各种统计数据。

http://www.cplusplus.com/src/

,,,,,,,,, ,,,,


当我编译它们时,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.


推荐答案

12月25日晚上10点15分,fl< rxjw ...... @ gmail.comwrote:
On Dec 25, 10:15 pm, fl <rxjw...@gmail.comwrote:



我正在从以下C ++网站学习C ++,其中有一些非常好的

很好的小例子。对于第二个Fraction示例,它有五个

文件:


Main.cpp

Fraction.cpp

Fraction.h

msoftcon.cpp

msoftcon.h

,,,,,

A分数类能够加,减,乘,
除以并显示分数的各种统计数据。

http://www.cplusplus.com/src/

,,,,,,,,, ,,,,


当我编译它们时,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?


25déc,23:12,johanatan< johana ... @ gmail.comwrote:
On 25 déc, 23:12, johanatan <johana...@gmail.comwrote:

12月25日晚上10点15分,fl< rxjw ... @ gmail.comwrote:


On Dec 25, 10:15 pm, fl <rxjw...@gmail.comwrote:





我正在从以下C ++网站学习C ++,这里有一些非常好的小bb b个小例子。对于第二个Fraction示例,它有五个

文件:
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

,,,,,

一个Fraction类,它能够加,减,乘,
除以显示分数的各种统计数据。
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 /

,,,,,,,,,,,,,
http://www.cplusplus.com/src/
,,,,,,,,,,,,,


当我编译它们时,MSVC 6 ++编译器说:
When I compile them, MSVC 6++ compiler says:


error C2653:''Fraction'':不是类或命名空间名称

如果我将Fraction.h与.cpp一起放在Source Files类别下。
error C2653: ''Fraction'' : is not a class or namespace name
if I put Fraction.h with the .cpp under Source Files category.


如果我把Fraction.h放在Header Files类别下,那么编译器就会发现.h
找到.h文件。我也在项目菜单中尝试过设置

但没有成功。我是MSVC和C ++的新手,你能帮我设置

吗?非常感谢你。
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? - 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.


fl写道:
fl wrote:



我正在学习C ++来自下面的C ++网站,其中有一些非常好的b $ b好​​小例子。对于第二个Fraction示例,它有五个

文件:


Main.cpp

Fraction.cpp

Fraction.h

msoftcon.cpp

msoftcon.h

,,,,,

A分数类能够加,减,乘,
除以并显示分数的各种统计数据。

http://www.cplusplus.com/src/

,,,,,,,,, ,,,,


当我编译它们时,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.



您必须在源文件中包含标头。你的书应该

解释一下。



Brian

You have to include the header in the source file. Your book should
explain this.


Brian


这篇关于为什么MSVC 6 ++找不到.h文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆