I really hope someone can help with this...We've been working on the same 'core' abstract data type files (ListA.h & ListA.cpp) thus far this semester. Progressively adding different methods along with the new concepts introduced. AppointmentBook is our class, and each project calls for some implementation of a simulated appointment book; here included, in addition to the core or 'encapsulated' files if you will, app.h, appt.cpp, and testP1.cpp.
The directions are to implement the following:
AppointBook() default constructor
Appointment Book() overloaded constructor
bool isAppointment(string date, string time)
void makeAppointment(string date, string time, string purpose, bool &success) ----- If there is already a date and time, or if the format of the date /or time is unacceptable (this aspect can be dealt with later), return with success set false. Else, make the appointment entry and set success to true.
....There are more, however, I'm not good at this at all, and I figured I better start testing the first two......
I keep getting linker 2019's for each: unresolved external symbol public: bool_this call isAppointment; void_this call makeAppointment; and _this call AppointmentBook::AppointmentBook(). I've tried taking out my constructor, altering my methods, nothing is working!!!
Thank you

//His header file
// *********************************************************
// Header file ListA.h for the ADT list
// Array-based implementation
//   2004 0119 sbw added #ifnedef and namespace...
// *********************************************************
// Must define ListItemType and MAX_LIST before compilation

#ifndef LISTA_H
#define LISTA_H

const int MAX_LIST = 10;  //MODIFY!!!
#include <iostream>
#include <string>
using namespace std;
struct Appointment
{
	string date;
	string time;
	string purpose;
};
typedef Appointment ListItemType;  //MODIFY!!!

class List

{
public:

   List(); // default constructor
           // destructor is supplied by compiler

// list operations:
   bool isEmpty() const;
   // Determines whether a list is empty.
   // Precondition: None.
   // Postcondition: Returns true if the list is empty;
   // otherwise returns false.

   int getLength() const;
   // Determines the length of a list.
   // Precondition: None.
   // Postcondition: Returns the number of items
   // that are currently in the list.

   void insert(int index, ListItemType newItem,
               bool& success);
   // Inserts an item into the list at position index.
   // Precondition: index indicates the position at which
   // the item should be inserted in the list.
   // Postcondition: If insertion is successful, newItem is
   // at position index in the list, and other items are
   // renumbered accordingly, and success is true;
   // otherwise success is false.
   // Note: Insertion will not be successful if
   // index < 1 or index > getLength()+1.

   void remove(int index, bool& success);
   // Deletes an item from the list at a given position.
   // Precondition: index indicates where the deletion
   // should occur.
   // Postcondition: If 1 <= index <= getLength(),
   // the item at position index in the list is
   // deleted, other items are renumbered accordingly,
   // and success is true; otherwise success is false.

   void retrieve(int index, ListItemType& dataItem,
                 bool& success) const;
   // Retrieves a list item by position.
   // Precondition: index is the number of the item to
   // be retrieved.
   // Postcondition: If 1 <= index <= getLength(),
   // dataItem is the value of the desired item and
   // success is true; otherwise success is false.

void display();

private:
   ListItemType items[MAX_LIST]; // array of list items
   int          size;            // number of items in list

   int translate(int index) const;
   // Converts the position of an item in a list to the
   // correct index within its array representation.
}; // end List class

#endif
// End of header file.

//HIs implementation

// *********************************************************
// Implementation file ListA.cpp for the ADT list
// Array-based implementation   //Carrano 3rd
// *********************************************************

#include "ListA.h" //header file
//#include "Appt.h" // new header file

List::List() : size(0)
{
} // end default constructor

bool List::isEmpty() const
{
   return bool(size == 0);
} // end isEmpty

int List::getLength() const
{
   return size;
} // end getLength

void List::insert(int index, ListItemType newItem,
                  bool& success)
{
   success = bool( (index >= 1) &&
                   (index <= size+1) &&
                   (size < MAX_LIST) );
   if (success)
   {  // make room for new item by shifting all items at
      // positions >= index toward the end of the
      // list (no shift if index == size+1)
      for (int pos = size; pos >= index; --pos)
         items[translate(pos+1)] = items[translate(pos)];

      // insert new item
      items[translate(index)] = newItem;
      ++size; // increase the size of the list by one
   } // end if
} // end insert

void List::remove(int index, bool& success)
{
   success = bool( (index >= 1) && (index <= size) );

   if (success)
   {  // delete item by shifting all items at positions >
      // index toward the beginning of the list
      // (no shift if index == size)
      for (int fromPosition = index+1;
               fromPosition <= size; ++fromPosition)
         items[translate(fromPosition-1)] =
                             items[translate(fromPosition)];
      --size; // decrease the size of the list by one
   } // end if
} // end remove

void List::retrieve(int index, ListItemType& dataItem,
                    bool& success) const
{
   success = bool( (index >= 1) &&
                   (index <= size) );

   if (success)
      dataItem = items[translate(index)];
} // end retrieve

int List::translate(int index) const
{
   return index-1;
} // end translate


void List::display()
{

	ListItemType data;
	bool s;

	cout <<  " ---List contains " << getLength() << "items ---" << endl;
	for(int i=1; i<=getLength(); i++)
	{
		retrieve(i, data, s);
		cout << data.date << endl;
		cout << data.time << endl;
		cout << data.purpose << endl << endl;
	}
		cout << "---------end of list______" << endl;
}	


	




// End of implementation file.

//MY HEADER
#ifndef appt_h
#define appt_h
#include "ListA.h"

using namespace std;                 //PROJECT 1



class AppointmentBook
{
public:
	string the_date, the_time, the_purpose;
	AppointmentBook();
	AppointmentBook::AppointmentBook(string the_date, string the_time, string the_purpose);
	bool isAppointment(string the_date, string the_time);
	void makeAppointment(string the_date, string the_time, string the_purpose, bool &success);
	void cancelAppointment(string the_date, string the_time, string the_purpose, bool &success);
	void checkAppointment(string the_date, string the_time, string &the_purpose, bool &success);

private:

	List myAppList;
	
};
#endif

//MY IMPLEMENTATION
#include "appt.h"
#include <iostream>
using namespace std;                  //PROJECT 1
//Project 1


	AppointmentBook::AppointmentBook()
	{
	}
	AppointmentBook::AppointmentBook(string the_date, string the_time, string the_purpose)
	{
		Appointment simulator;
		simulator.date = the_date;
		simulator.time = the_time;
		simulator.purpose = the_purpose;
	}
	ListItemType data;


	void AppointmentBook::makeAppointment(std::string the_date, std::string the_time, std::string the_purpose, bool &success)
	{

		Appointment simulator;
		
		myAppList.insert(1, data, success);
		myAppList.retrieve(1, data, success);
	}


	bool AppointmentBook::isAppointment(string the_date, string the_time)

	{
		Appointment simulator;
		

		if(myAppList.getLength() >= 1)
		{
		return true;
		}
	
return 0;
	}

//MY MAIN
#include <iostream>
#include "ListA.h"
#include "appt.h"
#include <string>

using namespace std;

int main()
{
	AppointmentBook tester;
	string x,y;
	bool success;
	
	tester.makeAppointment("12/33/44", "11:00", "do stuff", success);
	{
		
	}
	
	tester.isAppointment(x,y);
	
	{
			cout << "Appointments available" << endl;
	}

return 0;
}

Recommended Answers

All 4 Replies

Could someone please hit me with a brick???????
I just figured it out after I posted this!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
I forgot to comment out my other methods in my header........................................
Thanks anyway....I'm sure I'll need more help though before this is through.
-RG

Bla Bla Bla: Hit me with 2 bricks.........I don't know what I thought I compiled but It Still Doesn't Work!

Appears as if you were not having the corresponding .cpp included in scope of compile/link, i.e. the one in which you've implemented e.g. AppointmentBook::AppointmentBook() ...

It appears you have the ......
It helps when you place your test file where VS can find it!!
Thank you

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.