I'm fairly new to C++ and my professor gave me most of the code to start with. I'm supposed to write a program that uses the add_day(int n) function I wrote in Chrono.cpp.
There must be a problem with the Chrono::Date add_day(int n); line.

Here is the error:
hw4pr2.obj : error LNK2019: unresolved external symbol "class Chrono::Date __cdecl add_day(int)" (?add_day@@YA?AVDate@Chrono@@H@Z) referenced in function _main

//file hw4pr2.cpp
#include "Chrono.h"
#include "std_lib_facilities_3.h"

    int main()
    {
        Chrono::Date date; //declaring our date variable from the Chrono.cpp file
        Chrono::Date add_day(int n); //This is where the error has to be
        cout << "Enter a date with the format (year,month,day):\n"; //asks user to input date in that format

        while(cin >> date){ //input date
        if(!cin) //bad input date
        {
            cout << "Wrong format. Closing...\n";
            return 1;
        }
        ++date; //increment the date with specifications to Chrono.cpp and Chrono.h
        cout << "Tomorrow is: " << date << "\n"; //reads out the date
        cout << "Two days from now is " << add_day(2);
    }
        keep_window_open();
        return 0;
    }

please copy here the content of Chrono.h and Chrono.cpp.
Also, if your function add_day is in a separate file, include it as well

I worked on them for a couple hours last night and was able to solve the initial problem I was having. Now when I use the add_day function it just skips through the loop and displays the input date instead of it being incremented.

Here are the areas that need working on but I'll post the document below as well.

add_day function in Chrono.cpp: When I run my main in hw4pr2.cpp i get an output of "01(y,m,d)" the 01 part is just my debugging and the y,m,d is the input date and not incremented as it should.

void Date::add_day(int n)
    {       
        Chrono::Date date;
        for(int i=0; i<n; ++i){
            cout<< i; //debugging
            ++date;
        }
    }

But when I set up a function I called add_d above my main IN hw4pr2.cpp it works perfectly. Here is the code for that one:

Chrono::Date date;
void add_d(int n)
    {         
        for(int i=0; i<n; ++i){
            ++date;
        }
    }

Same thing right?
Here are the links to the documents. In hw4pr2.cpp I removed parts of the code by making them notes so ignore those parts.
hw4pr2.cpp: https://docs.google.com/open?id=0BwFIoFZkTzlqNV9CcXp6T1duam8
Chrono.cpp: https://docs.google.com/open?id=0BwFIoFZkTzlqWkV4ZjYyY3NkN00
Chrono.h: https://docs.google.com/open?id=0BwFIoFZkTzlqVDdDZjRnS1YxZmM

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.