I looked at the other questions already asked on SO regarding this same error message. They say to make sure my definition matches my implementation, and it does (I think). I have multiple classes, linkedListType (base template class), unorderedLinkedList (derived template class), main for testing it and a few others (can post snippets if needed).   When compiling it, I get this error:  Undefined symbols for architecture x86_64:   "linkedListType&lt;int&gt;::deleteAtIndex(int&amp;)", referenced from:       deleteKthElement(unorderedLinkedList&lt;int&gt;&amp;) in main.cpp.o   "linkedListType&lt;int&gt;::getInfoAtIndex(int)", referenced from:       printKthElement(unorderedLinkedList&lt;int&gt;&amp;) in main.cpp.o       deleteKthElement(unorderedLinkedList&lt;int&gt;&amp;) in main.cpp.o   "linkedListType&lt;int&gt;::linkedListType()", referenced from:       unorderedLinkedList&lt;int&gt;::unorderedLinkedList() in main.cpp.o   "linkedListType&lt;int&gt;::~linkedListType()", referenced from:       unorderedLinkedList&lt;int&gt;::~unorderedLinkedList() in main.cpp.o   "unorderedLinkedList&lt;int&gt;::deleteNode(int const&amp;)", referenced from:       vtable for unorderedLinkedList&lt;int&gt; in main.cpp.o   "unorderedLinkedList&lt;int&gt;::insertLast(int const&amp;)", referenced from:       vtable for unorderedLinkedList&lt;int&gt; in main.cpp.o   "unorderedLinkedList&lt;int&gt;::insertFirst(int const&amp;)", referenced from:       vtable for unorderedLinkedList&lt;int&gt; in main.cpp.o   "unorderedLinkedList&lt;int&gt;::deleteSmallest()", referenced from:       vtable for unorderedLinkedList&lt;int&gt; in main.cpp.o   "unorderedLinkedList&lt;int&gt;::deleteAllOccurrences(int&amp;)", referenced from:       vtable for unorderedLinkedList&lt;int&gt; in main.cpp.o   "unorderedLinkedList&lt;int&gt;::deleteFirstOccurrence(int&amp;)", referenced from:       vtable for unorderedLinkedList&lt;int&gt; in main.cpp.o   "linkedListType&lt;int&gt;::printListReverse() const", referenced from:       reversePrint(unorderedLinkedList&lt;int&gt;&amp;) in main.cpp.o   "linkedListType&lt;int&gt;::print() const", referenced from:       print(unorderedLinkedList&lt;int&gt;&amp;) in main.cpp.o   "linkedListType&lt;int&gt;::length() const", referenced from:       printKthElement(unorderedLinkedList&lt;int&gt;&amp;) in main.cpp.o       deleteKthElement(unorderedLinkedList&lt;int&gt;&amp;) in main.cpp.o   "unorderedLinkedList&lt;int&gt;::search(int const&amp;) const", referenced from:       vtable for unorderedLinkedList&lt;int&gt; in main.cpp.o   Looking at the first one (deleteAtIndex):   linkedListType.h:  template&lt;class Type&gt; class linkedListType { public:    ...    void deleteAtIndex(int&amp; desiredIndex); }   linkedListType.cpp:   template&lt;class Type&gt; void linkedListType&lt;Type&gt;::deleteAtIndex(int&amp; desiredIndex) {     nodeType&lt;Type&gt; *temp = getNodeAtIndex(desiredIndex);     nodeType&lt;Type&gt; *priorNode = getNodeAtIndex(desiredIndex-1);     priorNode-&gt;link = temp-&gt;link;     delete temp; }   main.cpp:  // a convenience function in main.cpp... both 'getInfoAtIndex' and 'deleteAtIndex' only exist in the base class void deleteKthElement(unorderedLinkedList&lt;int&gt; &amp;ull){      int elem;     cout &lt;&lt; "Enter an integer specifying the index to delete (0 - " &lt;&lt; ull.length() - 1 &lt;&lt; "): ";     cin &gt;&gt; elem;     int info = ull.getInfoAtIndex(elem);     cout &lt;&lt; "Info at index (" &lt;&lt; elem &lt;&lt; "): " &lt;&lt; info &lt;&lt; endl;     ull.deleteAtIndex(elem);     cout &lt;&lt; "Node deleted." &lt;&lt; endl; }   I have no idea why these functions are giving me these errors.
341
Quote from :     The only portable way of using templates at the moment is to implement them in header files by using inline functions.   Why is this?  (Clarification: header files are not the only portable solution. But they are the most convenient portable solution.)
8017
I often find myself in a situation where I am facing multiple compilation/linker errors in a C++ project due to some bad design decisions (made by someone else :) ) which lead to circular dependencies between C++ classes in different header files (can happen also in the same file). But fortunately(?) this doesn't happen often enough for me to remember the solution to this problem for the next time it happens again.  So for the purposes of easy recall in the future I am going to post a representative problem and a solution along with it. Better solutions are of-course welcome.     A.h  class B; class A {     int _val;     B *_b; public:      A(int val)         :_val(val)     {     }      void SetB(B *b)     {         _b = b;         _b-&gt;Print(); // COMPILER ERROR: C2027: use of undefined type 'B'     }      void Print()     {         cout&lt;&lt;"Type:A val="&lt;&lt;_val&lt;&lt;endl;     } };       B.h  #include "A.h" class B {     double _val;     A* _a; public:      B(double val)         :_val(val)     {     }      void SetA(A *a)     {         _a = a;         _a-&gt;Print();     }      void Print()     {         cout&lt;&lt;"Type:B val="&lt;&lt;_val&lt;&lt;endl;     } };       main.cpp  #include "B.h" #include &lt;iostream&gt;  int main(int argc, char* argv[]) {     A a(10);     B b(3.14);     a.Print();     a.SetB(&amp;b);     b.Print();     b.SetA(&amp;a);     return 0; }
6108
Why do I get compiler errors with this Java code?  1  public List&lt;? extends Foo&gt; getFoos() 2  { 3    List&lt;? extends Foo&gt; foos = new ArrayList&lt;? extends Foo&gt;(); 4    foos.add(new SubFoo()); 5    return foos; 6  }  Where 'SubFoo' is a concrete class that implements Foo, and Foo is an interface.  Errors I get with this code:   On Line 3: "Cannot instantiate ArrayList&lt;? extends Foo&gt;" On Line 4: "The method add(capture#1-of ? extends Foo) in the type List&lt;capture#1-of ? extends Foo&gt; is not applicable for the arguments (SubFoo)"   Update: Thanks to Jeff C, I can change Line 3 to say "new ArrayList&lt;Foo&gt;();".  But I'm still having the issue with Line 4.
5129
I've scoured this forum and it looks to me like I'm setting up the tree correctly, but I'm still getting this error, I have   \usepackage{tikz} \usepackage{tikz-qtree}   in the header.  Here is the code that is causing the problem:  \begin{tikzpicture}  \Tree  [.{Boolean Groups}     [.{Abelian Groups}         [.Groups]     ]     [.{Class 3}          [.{Class 5}]         [.{Class 1}]         [.{Class 2}]         [.{Class 4}]     ] ]  \end{tikzpicture}
92550
I am receiving the following error.     Constructor not defined: [DynamicBatchApex].(String, String, Map, String) (Line: 9, Column: 30)   If you look at my DynamicBatchApex class, I clearly have the constructor outlined.  Also, what are the positives and downsides of using the global header?   global class NumberOfEmailsSchedulable implements Schedulable {       global void execute(SchedulableContext sc)        {      String query1 = 'SELECT accountId accountId, count( Id) result FROM contact WHERE accountid != null GROUP BY accountId';     Map&lt;String, Object&gt; field_value_pairs = new Map&lt;String, Object&gt;{'Number_Of_Contacts__c' =&gt; 0};     DynamicBatchApex batch1     =   new DynamicBatchApex('accountId', 'result', field_value_pairs, query1);       } }   Batch Apex Class  global class DynamicBatchApex implements Database.Batchable&lt;AggregateResult&gt; {  public String sObjectIdKey; public String sObjectResultKey; public Map&lt;String, Object&gt; sObjectFieldsToUpdate; public String query;   global DynamicBatchApex(String arIdKey, String arResultKey, Map&lt;String, Object&gt; field_value_pairs, String fieldName, String soqlQuery )  {       sObjectIdKey            = arIdKey;     sObjectResultKey        = arResultKey;      sObjectFieldsToUpdate   = field_value_pairs;     query                   = soqlQuery; }  global Iterable&lt;AggregateResult&gt; start(Database.BatchableContext BC)  {     return new BulkIterable(query); }  global void execute(Database.BatchableContext BC, List&lt;sObject&gt; scope)  {      DynamicSObjectUpdater sObjectUpdater = new DynamicSObjectUpdater();      for(sObject sObj: scope)     {         AggregateResult ar      = (AggregateResult)sObj;         ID sObjectId            = (ID)ar.get(sObjectIdKey);         Decimal arResult        = (Decimal)ar.get(sObjectResultKey);          sObjectUpdater.getUpdateSObject(sObjectId, sObjectFieldsToUpdate);     }      sObjectUpdater.updateSObjects();   }  global void finish(Database.BatchableContext BC)  {  } }
55385
This is one of the possible ways I come out:  struct RetrieveKey {     template &lt;typename T&gt;     typename T::first_type operator()(T keyValuePair) const     {         return keyValuePair.first;     } };  map&lt;int, int&gt; m; vector&lt;int&gt; keys;  // Retrieve all keys transform(m.begin(), m.end(), back_inserter(keys), RetrieveKey());  // Dump all keys copy(keys.begin(), keys.end(), ostream_iterator&lt;int&gt;(cout, "\n"));   Of course, we can also retrieve all values from the map by defining another functor RetrieveValues.  Is there any other way to achieve this easily? (I'm always wondering why std::map does not include a member function for us to do so.)
108407
I've just ported over and updated a bunch of FBX model loading code I had that worked with Direct X 10 to try and make it work with Direct X 11. Since that time, the FBX SDK I was using has been updated.   In my old program I linked to the following lib:  fbxsdk-2012.2-mdd.lib   Now, clearly I can't link to this as I don't have 2012.2 on my system. So, my thinking would be simply changing 2012.2 to 2014.1, but this didn't work and lead to the following error:  error LNK1104: cannot open file 'fbxsdk-2014.1-mdd.lib'    So I tried to some googleing to see what the updated version of fbxsdk-2012.2-mdd.lib is. But I can't find anything. I tried taking out linking ot the 2014.1 lib but I get the following errors:     Error 36  error LNK2019: unresolved external symbol "void __cdecl fbxsdk_2014_1::FbxAssert(char const *,char const *,unsigned int,char const *)" (?FbxAssert@fbxsdk_2014_1@@YAXPBD0I0@Z) referenced in function "public: int &amp; __thiscall fbxsdk_2014_1::FbxArray::operatorconst " (??A?$FbxArray@H@fbxsdk_2014_1@@QBEAAHH@Z)    So, looking in the FBX sample directory I opened up the ViewScene sample to see what it lib it linked to and I see that it wanted the following:  libfbxsdk-md.lib   So I did the same. But, my program claims it cannot open the file. And I'm at a loss as to what to do next.   Has anyone successfully managed to load FBX models into a Directx 11 application using 2014.1? If so, what do I need to do to get the correct lib linked?
16612
I have got a template class as follows:  class MyClass&lt;T&gt; {     T field;     public void myMethod()     {        field = new T(); // gives compiler error     } }   How do I create a new instance of T in my class?
81821
In the  library, they are overloading the () operator.  Is this a convention in C++? For callbacks, etc.?  I have seen this in code of a co-worker (who happens to be a big Boost fan). Of all the Boost goodness out there, this has only led to confusion for me.  Any insight as to the reason for this overload?
19841
I've been programming in C++ for a few years, and I've used STL quite a bit and have created my own template classes a few times to see how it's done.  Now I'm trying to integrate templates deeper into my OO design, and a nagging thought keeps coming back to me: They're just a macros, really... You could implement (rather UGLY) auto_ptrs using #defines, if you really wanted to.  This way of thinking about templates helps me understand how my code will actually work, but I feel that I must be missing the point somehow. Macros are meant evil incarnate, yet "template metaprogramming" is all the rage.  So, what ARE the real distinctions? and how can templates avoid the dangers that #define leads you into, like   Inscrutable compiler errors in places where you don't expect them? Code bloat?  Difficulty in tracing code? Setting Debugger Breakpoints?
12470
Why do we need to use:  extern "C" { #include &lt;foo.h&gt; }   Specifically:     When should we use it? What is happening at the compiler/linker level that requires us to use it?   How in terms of compilation/linking does this solve the problems which require us to use it?
15725
I've been getting this undefined symbol building with this command line:  $ gcc test.cpp Undefined symbols:   "___gxx_personality_v0", referenced from:   etc...   test.cpp is simple and should build fine.  What is the deal?
14363
What is the best way to initialize a private, static data member in C++?  I tried this in my header file, but it gives me weird linker errors:  class foo {     private:         static int i; };  int foo::i = 0;   I'm guessing this is because I can't initialize a private member from outside the class.  So what's the best way to do this?
18976
Is it possible to write a template that changes behavior depending on if a certain member function is defined on a class?  Here's a simple example of what I would want to write:  template&lt;class T&gt; std::string optionalToString(T* obj) {     if (FUNCTION_EXISTS(T-&gt;toString))         return obj-&gt;toString();     else         return "toString not defined"; }   So, if class T has toString() defined, then it uses it; otherwise, it doesn't. The magical part that I don't know how to do is the "FUNCTION_EXISTS" part.
113560
I expected A::~A() to be called in this program, but it isn't:  #include &lt;iostream&gt;  struct A {   ~A() { std::cout &lt;&lt; "~A()" &lt;&lt; std::endl; } };  void f() {   A a;   throw "spam"; }  int main() { f(); }   However, if I change last line to   int main() try { f(); } catch (...) { throw; }   then A::~A() is called.  I am compiling with "Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86" from Visual Studio 2005. Command line is cl /EHa my.cpp.  Is compiler right as usual? What does standard say on this matter?
8198
I am writing a small matrix library in C++ for matrix operations. However my compiler complains, where before it did not. This code was left on a shelf for 6 months and in between I upgraded my computer from debian etch to lenny (g++ (Debian 4.3.2-1.1) 4.3.2 ) however I have the same problem on a Ubuntu system with the same g++.  Here is the relevant part of my matrix class:  namespace Math {     class Matrix     {     public:          [...]          friend std::ostream&amp; operator&lt;&lt; (std::ostream&amp; stream, const Matrix&amp; matrix);     } }   And the "implementation":  using namespace Math;  std::ostream&amp; Matrix::operator &lt;&lt;(std::ostream&amp; stream, const Matrix&amp; matrix) {      [...]  }   This is the error given by the compiler:     matrix.cpp:459: error: 'std::ostream&amp;   Math::Matrix::operator&lt;&lt;(std::ostream&amp;,   const Math::Matrix&amp;)' must take   exactly one argument   I'm a bit confused by this error, but then again my C++ has gotten a bit rusty after doing lots of Java those 6 months. :-)
102790
For deployment reasons, I am trying to use IJW to wrap a C# assembly in C++ instead of using a COM Callable Wrapper.    I've done it on other projects, but on this one, I am getting an EEFileLoadException.  Any help would be appreciated!  Managed C++ wrapper code (this is in a DLL):  extern "C" __declspec(dllexport) IMyObject* CreateMyObject(void) {     //this class references c# in the constructor     return new CMyWrapper( ); }  extern "C" __declspec(dllexport)  void DeleteMyObject(IMyObject* pConfigFile) {     delete pConfigFile; }  extern "C" __declspec(dllexport) void TestFunction(void) {     ::MessageBox(NULL, _T("My Message Box"), _T("Test"), MB_OK); }   Test Code (this is an EXE):  typedef void* (*CreateObjectPtr)(); typedef void (*TestFunctionPtr)();  int _tmain testwrapper(int argc, TCHAR* argv[], TCHAR* envp[]) {     HMODULE hModule = ::LoadLibrary(_T("MyWrapper"));     _ASSERT(hModule != NULL);      PVOID pFunc1 = ::GetProcAddress(hModule, "TestFunction");     _ASSERT(pFunc1 != NULL);     TestFunctionPtr pTest = (TestFunctionPtr)pFunc1;      PVOID pFunc2 = ::GetProcAddress(hModule, "CreateMyObject");     _ASSERT(pFunc2 != NULL);     CreateObjectPtr pCreateObjectFunc = (CreateObjectPtr)pFunc2;      (*pTest)();  //this successfully pops up a message box     (*pCreateObjectFunc)();  //this tosses an EEFileLoadException      return 0; }   For what it's worth, the Event Log reports the following: .NET Runtime version 2.0.50727.143 -  Fatal Execution Engine Error (79F97075) (80131506)  Unfortunately, Microsoft has no information on that error.