I'm working on an RPG (text based) for a school project. My teacher suggested using a header file for declearing the items side of things. The problem occurs in the data structure of the item:
1 2 3 4 5 6 7 8
struct itemdata
{
string iname //this is where the problem is.
itemtype itype //itemtype is a data type I made.
int idefence
int iattack
...
}irondagger ;
I included string before itemdata in both the main file and the header in all the different combinations just in case it mattered.
Also I am going to use a character array instead of a string; just want to know why it doesn't work.
The first then the third are usually recommended when declaring in the header file because the using declarations are carried over to all files that include that header file and its considered poor coding etiquette/practice to cloud the namespaces in other files.
And I agree with firedraco, a character array is not recommended. the string class has member functions that can convert them if needed and you will lose alot of simple, dynamic functionality.