Hello everyone
I have a problem with eclipse, when I declare a "string", eclipse say :
Type 'std::string' could not be resolved
but in an other project with this same .h the string works...
look :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
/*
* CPlayer.h
*
* Created on: 5 avr. 2012
* Author: Terrion
*/
#include <string>
#ifndef __CPLAYER_H__
#define __CPLAYER_H__
class CPlayer
{
private :
int m_Vie;
int m_Mana;
std::string m_NomArme; //dont work in RPG project but in Test projet
//it's work !
int m_DegatArme;
public :
void RecevoirDegat (int Degat) throw ();
void Attaquer (CPlayer cible) throw ();
void BoirePotion (int Quantite) throw ();
void ChangerArme (std::string Arme, int DegatNouvArme) throw (); //same
bool EstVivant () throw ();
};
#endif /* CPLAYER_H_ */
|
Last edited on
Make sure that you're using a C++ compiler. If you save your file as main.c and not as main.cpp or cxx or cc, you'd get such a problem.
u need using namespace std;
Aramil: no, he doesn't need that since he writes "std::" infront of "string" instead.
oh sorry i didnt see that ummm..... i dont understand throw but dont u need to put {} around the function defenitions?
throw ()
after the function declaration just means that the function will not throw any exceptions. It is similar to noexcept
in C++11.
Last edited on
In addition of Peter87's reply, it's considered a bad idea to use throw() as part of a function signature[1].
References:
[1] http://www.gotw.ca/publications/mill22.htm
Wazzak