When I run the code below with the private LinkedList declared without the static qualifier, it compiles and runs exactly as I expect. As soon as I add the static declaration, I get linker errors and it can't find the LinkedList. Any thoughts?
Code:#ifndef CS240_URL_SET_H #define CS240_URL_SET_H //Dustin Nicholes //October 21, 2008 //CS 240 //URLSet.h #include "URL.h" #include "LinkedList.h" #include "StringUtil.h" class URLSet { private: static LinkedList<URL> urlSet; public: URLSet() {} bool addURL(URL & url) { if(!Contains(url)) { urlSet.Insert(new URL(url), NULL); return true; } return false; } bool Contains(URL & url) { LLNode<URL> *LLCurrent; LLCurrent=urlSet.GetFirst(); string scheme = StringUtil::ToLowerCopy(url.getScheme()); string netLoc = StringUtil::ToLowerCopy(url.getNetLocation()); string path = url.getPath(); while(LLCurrent) { string otherString((LLCurrent->value)->toString()); URL other(otherString); string otherScheme = StringUtil::ToLowerCopy(other.getScheme()); string otherNetLoc = StringUtil::ToLowerCopy(other.getNetLocation()); string otherPath = other.getPath(); string thisString(scheme+netLoc+path); string thatString(otherScheme+otherNetLoc+otherPath); if(thisString.compare(thatString)==0) return true; LLCurrent = LLCurrent->next; } return false; } static bool Test(ostream & os) { os<<"Starting URL Set Test: "; bool success = true; string urlString("http://students.cs.byu.edu/~cs240ta/util_docs/"); URL url1(urlString); urlString="http://students.cs.byu.edu/~cs240ta/fall2008/"; URL url2(urlString); urlString="http://students.cs.byu.edu/~cs240ta/fall2008/TA/"; URL url3(urlString); urlString="HtTp://students.cs.byu.edu/~cs240ta/fall2008/TA/"; URL url4(urlString); urlString="http://students.cs.byu.edu/bogus/"; URL url5(urlString); URLSet testSet; TEST(testSet.addURL(url1)); TEST(testSet.addURL(url2)); TEST(testSet.addURL(url3)); TEST(!testSet.addURL(url4)); TEST(testSet.Contains(url1)); TEST(testSet.Contains(url2)); TEST(testSet.Contains(url3)); TEST(!testSet.Contains(url5)); if(success) os<<"Passed\r\n"; else os<<"Failed!!\r\b"; return success; } }; #endif