mallo
May 26th, 2007, 12:01 PM
Hi everybody,
I have a problem compiling a file that use a simple .h and its implementation .cpp.
I'm not so good at C programming so this is probably a stupid problem.
I don't understand very well in which file I need to include iostream ( the header in my opinion).
In the attachment there are the examples (the class is based on a similar/identical one on Deitel&Deitel programming book :P).
In a nutshell:
vector2d.h is the interface of vector2d.cpp. The aim is to create a 2d geometrical vector.
test.cpp implements a nutty main().
( Sorry in advance for comments that are in Italian).
I tried to compile it with:
g++ test.cpp -o test
or
g++ test.cpp vector2d.cpp vector2d.h -o test
but there are a lot of errors that look like this:
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/istream.tcc:1254: error: template with C linkage
For the :
vector2d.h:36: error: ISO C++ forbids declaration of ‘ostream’ with no type
you only need to uncomment using namespace std; but the other errors remain.
Anybody knows the correct syntax?:(
I have a problem compiling a file that use a simple .h and its implementation .cpp.
I'm not so good at C programming so this is probably a stupid problem.
I don't understand very well in which file I need to include iostream ( the header in my opinion).
In the attachment there are the examples (the class is based on a similar/identical one on Deitel&Deitel programming book :P).
In a nutshell:
vector2d.h is the interface of vector2d.cpp. The aim is to create a 2d geometrical vector.
test.cpp implements a nutty main().
( Sorry in advance for comments that are in Italian).
I tried to compile it with:
g++ test.cpp -o test
or
g++ test.cpp vector2d.cpp vector2d.h -o test
but there are a lot of errors that look like this:
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/istream.tcc:1254: error: template with C linkage
For the :
vector2d.h:36: error: ISO C++ forbids declaration of ‘ostream’ with no type
you only need to uncomment using namespace std; but the other errors remain.
Anybody knows the correct syntax?:(