Memo.h:
#ifndef _MEMO_H
#define _MEMO_H
#include <stdlib.h>
#include <string>
#include <typeinfo>
#include <iostream>
#include "Date.h"
#include <map>
#include <vector>
using namespace std;
class Memo {
public:
map<Date, vector<string> > Appointment;
//void delMemo(int x);
void addMemo(Date myDate,string x);
};
#endif /* _MEMO_H *
#include <stdlib.h>
#include <string>
#include <typeinfo>
#include <iostream>
#include "Date.h"
#include <map>
#include "Memo.h"
#include <vector>
using namespace std;
void Memo::addMemo(Date myDate, string myString)
{
vector<string> appt;
appt = Appointment[myDate];
appt.push_back(myString);
Appointment[myDate] = appt;
}
The above code gives me this compiler output:
Running "/usr/bin/make -f Makefile CONF=Debug" in /home/josh/Calendar
/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/josh/Calendar'
mkdir -p build/Debug/GNU-Linux-x86
g++ -c -g -o build/Debug/GNU-Linux-x86/Memo.o Memo.cc
/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_function.h: In member function 'bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = Date]':
/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_map.h:418: instantiated from '_Tp& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const _Key&) [with _Key = Date, _Tp = std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, _Compare = std::less<Date>, _Alloc = std::allocator<std::pair<const Date, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >]'
Memo.cc:22: instantiated from here
/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_function.h:230: error: no match for 'operator<' in '__x < __y'
make[1]: *** [build/Debug/GNU-Linux-x86/Memo.o] Error 1
make[1]: Leaving directory `/home/josh/Calendar'
make: *** [.build-impl] Error 2
Build failed. Exit value 2.
As a functional exercise, I'm working on a "Memo" class that will work together with my "Date" class to help me create a calendar program.
The "Memo" class, which is what I'm having trouble writing above, will be used to store information into various Dates. I decided to try this by using map<Date, vector<string> > as the storage type as this seems like it'll allow me the flexibility to store multiple strings into any Dates, but without having to use any more space than needed (and allowing the user to store as many strings as they'd like to a specific Date)
The code above doesn't compile correctly. Reading online some it seems I need to pass an operator function to my Memo class. But I'm pretty new to C++ and don't know how to do this correctly at all. I've seen a couple examples of how to, but I'm not sure how I would in my Memo class above. If this is indeed my problem, I'd appreciate help writing the code for this.
Thanks in advance. This seems like a really nice forum and I joined here specifically because it seems a strict philosophy is helping or teaching someone how to do something and not simply offering a solution (I really like that there are practice exercises in the stickies!)
-Josh
EDIT: Oh, I'm using g++ (gcc-4.3.4) as my compiler and write my code in NetBeans IDE 5.5.1. My OS is Gentoo Linux with the 2.6.31-gentoo-r6 kernel