Using a class file in main file

I'm having trouble working the two files together. I keep getting this error

error LNK2005: public:_thiscall datype::daytype(void)"(??0daytype@@QAE@XZ) already defined in createdaytype.obj

The same error are coming up for my printday function

Here is the daytype.cpp class code

#include <string>
#include <iostream>

class daytype {

public:

void setday(std::string day); //sets day
void printday()const; //prints day
std::string returnday()const; // returns day
std::string returnnextday()const; //returns next day
std::string returnpreviousday()const; //returns previous day
daytype(); //constructor





private:
std::string daylist[7];
int currentday; //holds index of array



};


daytype:: daytype(){

daylist[0] = "Sunday";
daylist[1] = "Monday";
daylist[2] = "Tuesday";
daylist[3] = "Wednesday";
daylist[4] = "Thursday";
daylist[5] = "Friday";
daylist[6] = "Satuday";
currentday=0;
} //constructor for the week


void daytype::printday() const {

std::cout << daylist[currentday] << std::endl;
}

void daytype::setday(std::string day){

for(int i = 0; i < 7;i++){
if(daylist[i] == day){
currentday = i;
break;
}//ends if
}//ends for loop

}

AND here is the main file createdatatype.cpp

#include <iostream>
#include "daytype.cpp"



int main() {

daytype week;
std::string weekday;
int daycount;


std::cout << "We are starting off with ";
week.printday();



system("pause");
return 0;
}

Thanks ats15 but I figured it out after an hour of reading a c++ book lol. But you nailed it!!
Topic archived. No new replies allowed.