Error C2011 using classes

This is my header file

#ifndef H_extPersonType
#define H_extpersonType
# include <iostream>
# include <string>

using namespace std;

class extPersonType
{
public:

void printPerson() const;
//Function to print: First Name, Last Name.

void setName(string first, string last);
//Function to set the full name.
//Postcondition string first name, string last name.

string getFirst() const;
//Function to return the first name.

string getLast() const;
//fucntion to return the last name.

extPersonType(string first="", string last="");
//constructor to initialize the variables.

private:
//Variables to store data.
string firstName;//First Name.
string lastName;//Last Name.
};
#endif

And I am still gettin the error C2011. I thought that using the;

#ifndef
#define

Will fix it, but it's not doing it. Any help please???
closed account (zb0S216C)
What is the full error?
The full error is probably something like this -> http://msdn.microsoft.com/en-us/library/sksadsda.aspx
Obviously, the error is not located in this header. Could we see some more code?
1>g:\lbcc\c12\martinezassig3\martinezassig3\extpersontype.h(19): error C2011: 'extPersonType' : 'class' type redefinition


Thats the full error, and that is the whole code for that header file
closed account (zb0S216C)
How many source files include this header?
I suppose none, because I'm using the header for my class, and a cpp file for the operations of my class, and then I have another cpp file for main program.
closed account (zb0S216C)
It's clear that the error doesn't live within the header file itself. Can you post both source files?
As an aside, putting using namespace std; at global scope in a header file is generally considered bad form, as anyone who ever includes that header file will have using namespace std; at the global scope level of their code and they won't even know it.
Last edited on
Cool, I looked at my other source files, and I took out extPersonType.h and it worked fine. What I dont understand is if I take out the using namespace std, my program wont work. Why is that???
Because you use std::strings. If you don't write using namespace std; at the top of your program, you will have to put std:: before everything that is in the std namespace.
Topic archived. No new replies allowed.