Nakor
November 23rd, 2004, 10:00 AM
Hi,
I have been told by someone on this board not to use the using directive in headers (or at least in the std instance) because it would force all .cpp files that included that header to use the std which may not be desirable. This makes sense to me, but I've run into a slight problem.
My problem is that I am trying to use strings in a class that I have written. I get aproximately 6 errors for every string that I include in my class. The only way I have been able to get these errors to dissappear is to put using namespace std; near the beginning of the header file. This conflicts with what I've been told however, so is this bad to do? Is there another way to use strings inside of my class?
#ifndef AAGOSELI_DVD_CLASS
#define AAGOSELI_DVD_CLASS
#include <string>
using namespace std;
const int MAX = 30;
class clsDVD
{
private:
string title;
char idNumber[MAX];
//string director;
//string date;
static int counter;
public:
clsDVD()
{ counter++; };
int getCount();
//void getData();
//void displayData(); // Display all data
//void displaySpecData(); // Display only specified data
};
#endif
Thanks,
Nakor
I have been told by someone on this board not to use the using directive in headers (or at least in the std instance) because it would force all .cpp files that included that header to use the std which may not be desirable. This makes sense to me, but I've run into a slight problem.
My problem is that I am trying to use strings in a class that I have written. I get aproximately 6 errors for every string that I include in my class. The only way I have been able to get these errors to dissappear is to put using namespace std; near the beginning of the header file. This conflicts with what I've been told however, so is this bad to do? Is there another way to use strings inside of my class?
#ifndef AAGOSELI_DVD_CLASS
#define AAGOSELI_DVD_CLASS
#include <string>
using namespace std;
const int MAX = 30;
class clsDVD
{
private:
string title;
char idNumber[MAX];
//string director;
//string date;
static int counter;
public:
clsDVD()
{ counter++; };
int getCount();
//void getData();
//void displayData(); // Display all data
//void displaySpecData(); // Display only specified data
};
#endif
Thanks,
Nakor