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

F

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

johanatan

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?
 
F

fl

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

Default User

fl said:
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
 
F

fl

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;
 
N

nullius.filius

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 :)
 
E

Erik Wikström

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

Default User

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
 
F

fl

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.

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
 
J

johanatan

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
 
Q

quangtin3

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

fl

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

quangtin3

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-Studio-Net-2003-CPP-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.
 
F

fl

You can follow this (I don't have VS now):http://www.ucancode.net/Visual-Studio-Net-2003-CPP-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.
 
N

nullius.filius

Erik said:
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.

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?
 
F

fl

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

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
files

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

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top