473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Why MSVC 6++ cannot find the .h file?

fl
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.


Dec 26 '07 #1
17 3090
On Dec 25, 10:15 pm, fl <rxjw...@gmail.comwrote:
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.
Did you #include "Fraction.h" in Main.cpp and Fraction.cpp?
Dec 26 '07 #2
fl
On 25 déc, 23:12, johanatan <johana...@gmail.comwrote:
On Dec 25, 10:15 pm, fl <rxjw...@gmail.comwrote:


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.

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 -
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.
Dec 26 '07 #3
fl wrote:
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.
You have to include the header in the source file. Your book should
explain this.


Brian
Dec 26 '07 #4
fl
On 25 déc, 23:23, "Default User" <defaultuse...@yahoo.comwrote:
fl wrote:
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.

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

Brian- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -
The Fraction.h is included in the main.cpp, see below.

// Allow the integer type to be changed on the fly
#define BIGGEST_INT int

#include <iostream.h// Include C++ input/output functions
#include <stdio.h> // Include C input/output functions
#include <conio.h // Include for pausing the program
#include <stdlib.h // Include C Library functions
#include "Fraction.h" // Includes the Fraction Header File
#include "msoftcon.h" // Allows more functionality to MVC++ console

int main() {
Fraction a;
Fraction b;
Fraction c;

-----
Thanks.
Dec 26 '07 #5
The example is broken, I am afraid you may have to spend some time
reading the code and debugging. It will be a good learning
experience :)

fl wrote:
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.
Dec 26 '07 #6
On 2007-12-26 04:15, fl wrote:
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:
A few tips if you want to learn C++:

1. While there are some websites out there which I would classify as
"not bad" there are none that I would consider "good", and they tend to
be very incomplete (not discussing important topics or only parts of
them). There are a number of good books out there, and if you search the
archives you can find a few that gets recommended often.

2. There are good compilers and there are bad compilers. MSVC++ 6 is one
of the worst, it is simply too old (almost 10 years now) and does not
support many features in C++. If you want to learn you have to get a
newer one, there are a number of gcc bases you can download, and
Microsoft's Visual C++ 2008 Express can also be downloaded for free.

--
Erik Wikström
Dec 26 '07 #7
fl wrote:
On 25 déc, 23:23, "Default User" <defaultuse...@yahoo.comwrote:
You have to include the header in the source file. Your book should
explain this.
The Fraction.h is included in the main.cpp, see below.
Post a complete, minimal program that demonstrates the problem. That
means the header files as well as the source. See the newsgroup FAQ
under "how to post".


Brian
Dec 26 '07 #8
fl
On 26 déc, 06:42, Erik Wikström <Erik-wikst...@telia.comwrote:
On 2007-12-26 04:15, fl wrote:
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:

A few tips if you want to learn C++:

1. While there are some websites out there which I would classify as
"not bad" there are none that I would consider "good", and they tend to
be very incomplete (not discussing important topics or only parts of
them). There are a number of good books out there, and if you search the
archives you can find a few that gets recommended often.

2. There are good compilers and there are bad compilers. MSVC++ 6 is one
of the worst, it is simply too old (almost 10 years now) and does not
support many features in C++. If you want to learn you have to get a
newer one, there are a number of gcc bases you can download, and
Microsoft's Visual C++ 2008 Express can also be downloaded for free.

--
Erik Wikström
Hi,
Thank all of you very much. In fact, I am reading the cpp primer of
lippman now. And I have one MS .net V7.1 enen though it is not a
English version. I have downloaded the source code of that book. But I
don't know the best way to use it, i.e. How to compile it as in the
readme.txt file? It says:

--------------------
To use make on a Windows operating system you invoke the command
name "nmake":

## Windows machines
nmake # compiles all the programs
nmake clean # removes all the object files and stackdumps
nmake clobber # removes executable, object and stackdump
files
--------------------
My computer doesn't understand the nmake command. Could you tell me
something about that? Thanks again.
Dec 27 '07 #9
On Dec 25, 11:23 pm, fl <rxjw...@gmail.comwrote:
On 25 déc, 23:12, johanatan <johana...@gmail.comwrote:
On Dec 25, 10:15 pm, fl <rxjw...@gmail.comwrote:
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.
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 -

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.
No need to #include the cpp. VC++ will compile the cpp if it is in
your 'source files' section of Solution Explorer (i.e., has been added
to the project).

--Jonathan
Dec 27 '07 #10
On Dec 25, 7:15 pm, fl <rxjw...@gmail.comwrote:
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.
I don't have MSVC 6.0 installed now, but after view the source code
(fraction2.zip ?), you can try this:
-Open MSVC 6.0 and create new "Window Console" project (select empty
project)
-Copy all file in fraction2 to your new project's folder
-In MSVC 6.0, in File view tab, chose add file in context menu to add
all files (just copy before)
If it does not compiled, let me know.
Dec 27 '07 #11
fl
On 26 déc, 20:28, johanatan <johana...@gmail.comwrote:
On Dec 25, 11:23 pm, fl <rxjw...@gmail.comwrote:


On 25 déc, 23:12, johanatan <johana...@gmail.comwrote:
On Dec 25, 10:15 pm, fl <rxjw...@gmail.comwrote:
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.
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 -
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.

No need to #include the cpp. *VC++ will compile the cpp if it is in
your 'source files' section of Solution Explorer (i.e., has been added
to the project).

--Jonathan- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -
Hi,
Now I am trying on MSVC 7.1. I find it is really complicated! I don't
know how to compile a simple .cpp file. I type namke in the bottom
window, nothing happens. Could you tell me to compile the simplest
win32 console example (which is from C++ primer book). Thank you very
much.
Dec 27 '07 #12
On Dec 26, 5:55 pm, fl <rxjw...@gmail.comwrote:
>
Hi,
Now I am trying on MSVC 7.1. I find it is really complicated! I don't
know how to compile a simple .cpp file. I type namke in the bottom
window, nothing happens. Could you tell me to compile the simplest
win32 console example (which is from C++ primer book). Thank you very
much.
You can follow this (I don't have VS now):
http://www.ucancode.net/Visual-Studi...P-Tutorial.htm
Open MSVC
-Create new project (File-New-Project)
-Select Visual C++ Project, and select Win32 (not .NET, in figure 2)
-In the right, select Window Console
-Select simple hello world project. After explorer your new project,
you will know where to paste your code.
Dec 27 '07 #13
fl
On 26 déc, 21:06, quangtin3 <quangt...@gmail.comwrote:
On Dec 26, 5:55 pm, fl <rxjw...@gmail.comwrote:
Hi,
Now I am trying on MSVC 7.1. I find it is really complicated! I don't
know how to compile a simple .cpp file. I type namke in the bottom
window, nothing happens. Could you tell me to compile the simplest
win32 console example (which is from C++ primer book). Thank you very
much.

You can follow this (I don't have VS now):http://www.ucancode.net/Visual-Studi...P-Tutorial.htm
Open MSVC
-Create new project (File-New-Project)
-Select Visual C++ Project, and select Win32 (not .NET, in figure 2)
-In the right, select Window Console
-Select simple hello world project. After explorer your new project,
you will know where to paste your code.
Thank you very much. It can run now. The only problem is that it
cannot run by Ctrl+F5 (with no debug mode running). The dialog box
says that:
It cannot start the program ......\...\xx.exe.
The path cannot be found.

In fact, the application xx.exe is right there. And I can exec it
directly in a command window. Where to config that? Thanks again.
Dec 27 '07 #14


Erik Wikström wrote:
2. There are good compilers and there are bad compilers. MSVC++ 6 is one
of the worst, it is simply too old (almost 10 years now) and does not
support many features in C++. If you want to learn you have to get a
newer one, there are a number of gcc bases you can download, and
Microsoft's Visual C++ 2008 Express can also be downloaded for free.

--
Erik Wikström
I am learning C++ from books that were written around the time that
MSVC 6 was released. For example, Stroustrup's C++ Programming
language 3rd edition. MSVC6 library seems to be complete (or
complete as far as Stroustrup's book is concerned.)

Bjarne Stroustrup in a recent video was talking about the direction of
C++.
He was saying MS compilers are not too bad at all.

What feature sets are missing from MSVC6 that make it such
a bad compiler?
Dec 27 '07 #15
fl
On 26 déc, 12:53, "Default User" <defaultuse...@yahoo.comwrote:
fl wrote:
On 25 déc, 23:23, "Default User" <defaultuse...@yahoo.comwrote:
You have to include the header in the source file. Your book should
explain this.
The Fraction.h is included in the main.cpp, see below.

Post a complete, minimal program that demonstrates the problem. That
means the header files as well as the source. See the newsgroup FAQ
under "how to post".

Brian
Thanks. The original files (Fraction.cpp and Fraction.h) have to be
combined together, I find. Thank you very much.
Dec 27 '07 #16
On 2007-12-27 01:26, fl wrote:
On 26 déc, 06:42, Erik Wikström <Erik-wikst...@telia.comwrote:
>On 2007-12-26 04:15, fl wrote:
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:

A few tips if you want to learn C++:

1. While there are some websites out there which I would classify as
"not bad" there are none that I would consider "good", and they tend to
be very incomplete (not discussing important topics or only parts of
them). There are a number of good books out there, and if you search the
archives you can find a few that gets recommended often.

2. There are good compilers and there are bad compilers. MSVC++ 6 is one
of the worst, it is simply too old (almost 10 years now) and does not
support many features in C++. If you want to learn you have to get a
newer one, there are a number of gcc bases you can download, and
Microsoft's Visual C++ 2008 Express can also be downloaded for free.

--
Erik Wikström

Hi,
Thank all of you very much. In fact, I am reading the cpp primer of
lippman now. And I have one MS .net V7.1 enen though it is not a
English version. I have downloaded the source code of that book. But I
don't know the best way to use it, i.e. How to compile it as in the
readme.txt file? It says:

--------------------
To use make on a Windows operating system you invoke the command
name "nmake":

## Windows machines
nmake # compiles all the programs
nmake clean # removes all the object files and stackdumps
nmake clobber # removes executable, object and stackdump
files
--------------------
My computer doesn't understand the nmake command. Could you tell me
something about that? Thanks again.
For help with a specific compiler you should ask in a group discussing
your compiler. Check out the groups in the microsoft.public.* hierarchy.

If you have installed VS7.1 correctly you should have something called
Visual Studio 7.1 Command Prompt somewhere on your start-menu, start
that and then navigate the where you have your code and run nmake.

--
Erik Wikström
Dec 27 '07 #17
On 2007-12-27 04:21, nu************@gmail.com wrote:
>
Erik Wikström wrote:
>2. There are good compilers and there are bad compilers. MSVC++ 6 is one
of the worst, it is simply too old (almost 10 years now) and does not
support many features in C++. If you want to learn you have to get a
newer one, there are a number of gcc bases you can download, and
Microsoft's Visual C++ 2008 Express can also be downloaded for free.

--
Erik Wikström

I am learning C++ from books that were written around the time that
MSVC 6 was released. For example, Stroustrup's C++ Programming
language 3rd edition. MSVC6 library seems to be complete (or
complete as far as Stroustrup's book is concerned.)
While it might look complete I am quite sure it is not.
Bjarne Stroustrup in a recent video was talking about the direction
of C++. He was saying MS compilers are not too bad at all.
He was talking about recent versions, the 2005 (and 2008) versions are
among the best available, comparable to gcc (but not as good as Comeau).
What feature sets are missing from MSVC6 that make it such
a bad compiler?
I seem to recall that the support for templates is not what it should be
(which affects the library) and I am sure that there are other things
that could be better.

--
Erik Wikström
Dec 27 '07 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Eric Brunel | last post by:
Hi all, We're trying to communicate with Microsoft Visual C++ 6.0 via COM to make it perform a few operations. Our main need is to set a breakpoint on a given line in a given file. We ended up...
2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
0
by: gok | last post by:
I did purchased msvc.net 2003 last year and downloaded msvc.net 2002 (a must for acad2004) from msdn. It was working fine forawhile and now after one week vacation can not open studio:...
4
by: user | last post by:
I am trying to port a simple vector/matrix class library to mingw (v3.4.2). I have used this library with no problem on MSVC++ v6 for a number of years. My difficulty is that it does not compile...
23
by: Babak | last post by:
Hi Everyone, I've written a standard C code for a simple finite element analysis in MSVC++ . When I save the file as a cpp file, it compiles and runs perfectly, but when I save it as a c file,...
29
by: Nindi | last post by:
I cannot get the following code to compile under MSVC 2003 or 2005. ........................................................................................... #include<stdio.h> struct...
1
by: reetugupta | last post by:
i have created a dialog based application for calender. coding is void CcalenderDlg::DblClickCalendar1() { CString cSelectedDate; char* cDay=""; char* cYear=""; ...
2
by: BruceWho | last post by:
I downloaded boost1.35.0 and built it with following command: bjam --toolset=msvc-7.1 --variant=release --threading=multi -- link=shared --with-system stage and it failed to compile, error...
1
by: Jim Langston | last post by:
I'm trying to compile some source code to interface LUA into C++. When I compile in MSVC++ Express 2008, however, I get the error (among others): ....\luastate.h(129) : error C2027: use of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.