ok im working with classes trying to figure them out i have the idea down you make a class to create objects like int,string etc. to make your variable types and stuff. so i copied this program out of the book and it compiles fine no errors however when i goto execute it i get the following errors and any explanation on the syntax of this would be appreciated as well cant seem to grasp that part to well either:
--------------------Configuration: displaydate - Win32 Debug--------------------
Linking...
displaydate.obj : error LNK2001: unresolved external symbol "public: void __thiscall date::assigndate(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,
class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?assigndate@date@@QAEXV?$basic_string@DU?$char_tr aits@D@std@@V?$allocator@D@2@@std@@00@Z)
Debug/displaydate.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
displaydate.exe - 2 error(s), 0 warning(s)
Code:
#include <string>
using namespace std;
class date
{
public:
//intializes variables
date();
//assigns program values to variables
void assigndate(string,string,string);
//returns formatted date
string getdate();
private:
string month;
string day;
string year;
};
//pmplentation section
date::date()
{
//constructor
month = "";
day = "";
year = "";
} // end of assigndate function
string date::getdate()
{
return month + "/" + day + "/" + year;
}//end of getdate function
Code:
#include <iostream>
#include <string>
#include "date.h"
using namespace std;
int main()
{
//create object
date dateobj;
//declare variables
string hiremonth = "";
string hireday = "";
string hireyear = "";
//get month day and year
cout << "Enter the month: ";
getline(cin,hiremonth);
cout << "Enter the day: ";
getline(cin,hireday);
cout << "Enter the year: ";
getline(cin,hireyear);
//set the date
dateobj.assigndate(hiremonth,hireday,hireyear);
//display the date
cout << "Employee hire date " << dateobj.getdate() << endl;
return 0;
}