please help me to fix this project showing lnk 2005 error on visual studio 2017

#pragma once
#include <iostream>
#include<string>

using namespace std;

const int MAXPARKINGSPACE = 100;

class carparked
{
private:
string carMake;
long carModel;
string carColor;
public:
carparked() //constructor
{
carMake = "";
carModel;
carColor = "";
}
string get_carMake();
long get_carModel();
string get_carColor();
};
class carParking :public carparked
{
private:

string licenseNo;
int count;
public:
carParking() // constructor
{
count = 0;
}

void read_time(int*hour, int* min, string s);
string get_licenseNo();
void print();
};
class car : public carParking
{
public:
int time_Inhour,time_Inmin,time_Outhour, time_Outmin, time,fare;
int get_time(int, int, int, int);
int get_amount(int);
void details(int , int , int, int, int , int );
};

cpp
#include <iostream>
#include<string>
#include <ctime>
#include <cmath>
#include "Header.h"
using namespace std;

string carparked::get_carColor()
{
cout << "Enter the Color of the Car\n:";
cin >> carColor;
return carColor;
}
string carparked::get_carMake()
{
cout << "Enter the Company (Manufacture Company) of the Car\n:";
cin >> carMake;
return carMake;
}
long carparked::get_carModel()
{
cout << "Enter the Model (year of manufacture) of the Car\n:";
cin >> carModel;
return carModel;
}
void carParking::read_time(int*hour, int*min, string s)
{
cout << "Enter " << s << " \nhours: ";
cin >> *hour;
// Hours ranging from 0 to 23 and minutes
//ranging from 0 to 59.
while ((*hour < 0 || *hour > 23) && *hour != 55 && *hour != 99)
{
cout << "Wrong input!(Please enter Hour can be between 0-23): ";
cin >> *hour;
}
if (*hour == 55 || *hour == 99)
{
*min = *hour;
return;
}
cout << "min: ";
cin >> *min;
while (*min < 0 || *min > 59)
{
cout << "Wrong input!(Please enter Minutes can be between 0-59): ";
cin >> *min;
}
}
string carParking::get_licenseNo()
{
cout << "Enter the license no \n" << endl;
cin >> licenseNo;
return licenseNo;
}

void carParking::print()
{
cout << "Car details \n" << endl;
cout << "License no \n" << get_licenseNo() << endl;


}
int car::get_time(int time_Inhour, int time_Inmin, int time_Outhour, int time_Outmin)
{
//Check the input 55 for the hour
// and 55 for the minutes
if (time_Outhour == 55 && time_Outmin == 55)
return -2;
//Check the input time of 99 for the hour
//and 99 for the minutes
if (time_Inhour == 99)
return -1;
if (time_Inhour <= time_Outhour)
return (time_Outhour - time_Inhour) * 60 + time_Outmin - time_Inmin;
return (time_Outhour + 24 - time_Inhour) * 60 + time_Outmin - time_Inmin;
}
int car::get_amount(int time)
{
//Check the drive has a special parking pass
if (time == -1)
return 5;
// Check the drive has lost their ticket
if (time == -2)
return 110;
// Less than 30 minutes
if (time <= 30)
return 3;
// Between 30 Minutes – 1 Hour
if (time <= 60)
return 5;
//Between 1 Hour – 2 Hours
if (time <= 120)
return 10;
//Between 2 Hours – 3 Hours
if (time <= 180)
return 15;
//Between 3 Hours – 4 Hours
if (time <= 240)
return 17;
//Each half hour over four hours
if (time <= 720)
return 20;
//error
return -1;

}
void car::details(int time_Inhour, int time_Inmin, int time_Outhour, int time_Outmin, int time, int Fare)
{
//Check the drive has a special parking pass
if (time_Inhour == 99)
cout << "The person has a special parking pass.Fare is $" << Fare << endl;
// Check the drive has lost their ticket
else if (time_Outhour == 55)
cout << "In-time: " << time_Inhour << ":" << time_Inmin << endl
<< "The drive has lost their ticket\nFare is: $" << Fare << endl;
else
cout << "In-time: " << time_Inhour << ":" << time_Inmin << endl << "Out-time:" << time_Outhour << ":" << time_Outmin << endl << "Total-time: " << time << "mins" << endl << "Fare is $" << Fare << endl;
}

main

// Project Parking payment Machine
// Project group Karanpreet Singh and Amitpal Singh

#include<iostream>
#include<cmath>
#include "Header.h"
#include "Source.cpp"

using namespace std;

int main()
{
carparked car1;
carParking car2;
car car3;


cout << " ******************* Welcome to Royal Center Parking****************** \n";
cout << "Choose the following options\n ";
cout << "Enter 1 if you want to park a Car";
cout << "Enetr 2 if you want to leave";
cout << "Enter 3 to exit the system\n";
int x;
cin >> x;
if (x == 1)
{

cout << "Enter the Details the system ask you:\n";
car1.get_carMake();
car1.get_carColor();
car1.get_carModel();
car2.get_licenseNo();

cout << "Thank you!! Your car has been parked!! ";

}

else if (x == 2)
{
int time_Inhour, time_Inmin, time_Outhour, time_Outmin, time, price;
cout << "Please Follow the instructions\n";
car2.read_time(&time_Inhour, &time_Inmin, "in-time");
car2.read_time(&time_Outhour, &time_Outmin, "out-time");
time = car3.get_time(time_Inhour, time_Inmin, time_Outhour, time_Outmin);
price = car3.get_amount(time);
car3.details(time_Inhour, time_Inmin, time_Outhour, time_Outmin, time, price);


}
else if (x == 3)
exit(0);

system("pause");
return 0;
}
Hello kannu,

Welcome to the forum.

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.

Please post the actual error message and what IDE or compiler you are using.

It could be that something is not set up right.

Andy
Hello kannu,

After figuring out that your code is in three sections I was able to duplicate your error.

Some notes first:

In the header file
1
2
3
4
#include <iostream>
#include<string>

using namespace std;

The include files should not be here. Only in the ".cpp" files.

Line 4. Should not be used and never be in a header file.
http://www.lonecpluspluscoder.com/2012/09/22/i-dont-want-to-see-another-using-namespace-xxx-in-a-header-file-ever-again/
Good reading.

The ".cpp" file that goes with the header file is OK exept line 7 which is redundant do to that line being in the header file.

The actual problem comes from the "main" file what would be about line 4 #include "Source.cpp" . This includes the code from this file twice when you compile the program. It is a very rare occasion when you include a ".cpp" like this and not something you are ready for at this time. Otherwise you should never include a ".cpp" file in another ".cpp" file. After removing this line from main the program compiled with no linker errors.

I have not tested a run yet to see what happens, but it is a step in the right direction.

Hope that helps,

Andy
Topic archived. No new replies allowed.