P
pmatos
Hi all,
I'm not used to programming in C++, in fact I just now started to
program in C++ after a 1 year detour through other exotic languages.
Even though I'm programming side by side with C++ Programming Language
Special Editions some issues raised in my program. I was able to
simplify my program to reproduce the errors. Let me tell you before
hand that this seems almost like the 10.4.6 example in the book cited
above so I can't possibly understand what's wrong.
// stest.h
#include <iostream>
#include <string>
class stest {
string name;
public:
stest(const string& n);
};
// stest.cpp
#include "stest.h"
stest::stest(const string & n)
: name(n) {
cout << "DONE" << nl;
}
Can someone explain me why when I try to compile stest.cpp into object
file with g++, I get:
$ g++ -ansi -Wall -c stest.cpp
In file included from stest.cpp:1:
stest.h:6: error: 'string' is used as a type, but is not defined as a
type.
stest.h:9: error: parse error before `&' token
stest.cpp:3: error: parse error before `&' token
Any suggestions on code style or any other comments are extremely
welcomed.
Cheers,
Paulo Matos
I'm not used to programming in C++, in fact I just now started to
program in C++ after a 1 year detour through other exotic languages.
Even though I'm programming side by side with C++ Programming Language
Special Editions some issues raised in my program. I was able to
simplify my program to reproduce the errors. Let me tell you before
hand that this seems almost like the 10.4.6 example in the book cited
above so I can't possibly understand what's wrong.
// stest.h
#include <iostream>
#include <string>
class stest {
string name;
public:
stest(const string& n);
};
// stest.cpp
#include "stest.h"
stest::stest(const string & n)
: name(n) {
cout << "DONE" << nl;
}
Can someone explain me why when I try to compile stest.cpp into object
file with g++, I get:
$ g++ -ansi -Wall -c stest.cpp
In file included from stest.cpp:1:
stest.h:6: error: 'string' is used as a type, but is not defined as a
type.
stest.h:9: error: parse error before `&' token
stest.cpp:3: error: parse error before `&' token
Any suggestions on code style or any other comments are extremely
welcomed.
Cheers,
Paulo Matos