I am trying to compile a class in which I created a data member that its type is of another class "objects", but something goes wrong during run time and it fails due to 10 errors all of the same error code and I really worked on this problem over and over .. The errors messages : LNK1169 one or more multiply defines symbols found LNK2005 some code of date and Event are already defined in obj Here is the code ( Note: in visual studio 2019, each class of the two classes is separated into h file and cpp file not like it appears below)
#pragma once
#include<iostream>
using namespace std;
class date
{
int day;
int month;
int year;
public:
date();
void readData();
~date();
};
#include"date.h"
date::date()
{
day = 0;
month = 0;
year = 0;
}
void date::readData()
{
cout << "Day: ";
cin >> day;
cout << "Month: ";
cin >> month;
cout << "Year: ";
cin >> year;
}
date::~date()
{
}
#pragma once
#include"date.cpp"
#include<string>
class Event
{
string name;
date start_date;
date end_date;
string place;
bool done;
public:
Event();
void Add();
~Event();
};
#include "Event.h"
Event::Event()
{
done = false;
}
void Event::Add()
{
cout << "Enter the event's name: ";
cin >> name;
cout << "Enter the event's start date:" << endl;
start_date.readData();
cout << "Enter the event's end date:" << endl;
end_date.readData();
cout << "Enter the event's place: ";
cin >> place;
}
Event::~Event()
{
}