Fehler in .obj Datei, nicht verstanden
-
Hi. Ich habe mal wieder ein Problem:
Irgendetwas stimmt nicht mit meiner Testklasse, ich verstehe aber nicht ganz was, ich verstehe mitlerweile ganz schön viele Fehler, exceptions, die in der Konsole ausgegeben werden, aber diesen hier nicht.
Mein Code:
// Console Library.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <string> #include "Console.h" #include "List.h" using namespace std; int _tmain(int argc, _TCHAR* argv[]) { Console console = Console(); console.setPrintBreak(20); List list = List(); list.setTitle("hi"); for(int i = 1;i<=10;i++) { list.addItem("Item_0"); } list.setTab(4); list.printList(console); return 0; }#include "StdAfx.h" #include <string> #include "Console.h" #include "List.h" #include <vector> using namespace std; // Attributes vector<string> items; string listTitle; string tab; char listChar; // Constrcutor List::List() { listChar = '-'; tab = " "; } // Methods void List::setTab(int n) { tab = (n,' '); } void List::setTitle(string s) { listTitle = s; } void List::setListChar(char c) { listChar = c; } char List::getListChar() { return listChar; } void addItem(string s) { items.push_back(s); } void printList(Console console) { console.println(listTitle+" :"); console.drawLine(); for(int i = 0;i<items.size();i++) { console.print(tab); console.print(listChar); console.print(" "); console.println(items[i]); } console.drawLine(); }Die Fehlermeldung:
1>------ Build started: Project: Console Library, Configuration: Debug Win32 ------ 1>Build started 02.06.2010 19:14:40. 1>InitializeBuildStatus: 1> Touching "Debug\Console Library.unsuccessfulbuild". 1>ClCompile: 1> All outputs are up-to-date. 1> List.cpp 1>f:\c++ projekte\console library\console library\list.cpp(52): warning C4018: '<' : signed/unsigned mismatch 1>ManifestResourceCompile: 1> All outputs are up-to-date. 1>Console Library Test.obj : error LNK2019: unresolved external symbol "public: void __thiscall List::printList(class Console)" (?printList@List@@QAEXVConsole@@@Z) referenced in function _wmain 1>Console Library Test.obj : error LNK2019: unresolved external symbol "public: void __thiscall List::addItem(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?addItem@List@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _wmain 1>F:\C++ Projekte\Console Library\Debug\Console Library.exe : fatal error LNK1120: 2 unresolved externals 1> 1>Build FAILED. 1> 1>Time Elapsed 00:00:01.60 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========Ich bin euch dankbar für all eure Hilfen, M.f.G. Developer_X
-
Hallo,
Du hast bei beiden Funktionen vergessen den Klassennamen davor zu schreiben
List::
-
"unresolved external symbol" bedeutet das du ein Symbol (Bezeichner) deklariert hast, aber nirgendwo definiert.
In diesem Fall benutzt du die Funktionen List::printList, doch hast du sie nirgendwo definiert. Du hast lediglich eine Funktion namens printList - die ist aber kein Member der Klasse List.
-
Du hast folgendes geschrieben:
void addItem(string s) { items.push_back(s); } void printList(Console console) // ...Vermutlich soll es so heißen:
void List::addItem(string s) //void addItem(string s) { items.push_back(s); } void List::printList(Console console) //void printList(Console console) // ...
-
Oh man, dass ich das nicht gesehen habe, danke, aber da war ich einfach zu blöd. Das ist echt ein lachhafter Fehler, auch für meiner Verhältnisse.
Ich danke euch sehr,
M.f.G. Developer_X