Hi all,
I'm having some trouble about linking my project with the IDE Visual Studio C++ 2008. If anyone could help me I would be thankful.
See code below:
ListNode.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#ifndef LISTNODE_H
#define LISTNODE_H
template< typename nodeType >
class ListNode
{
public:
ListNode( int, nodeType );
int getCode() const;
nodeType getValue() const;
void setCode( int );
void setValue( nodeType );
ListNode< typename nodeType >* getNextNode() const;
ListNode< typename nodeType >* getPrevNode() const;
void setNextNode( ListNode< typename nodeType >* );
void setPrevNode( ListNode< typename nodeType >* );
private:
int code;
nodeType value;
ListNode< typename nodeType >* nextNode;
ListNode< typename nodeType >* prevNode;
};
#endif
|
ListNode.cpp
1 2 3 4 5 6 7 8 9 10
|
#include <iostream>
using std :: cout;
using std :: cin;
using std :: endl;
#include "ListNode.h"
member function definitions
|
List.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#ifndef LIST_H
#define LIST_H
#include "ListNode.h"
template< typename nodeType >
class List
{
public:
List();
~List();
void addNode( int, nodeType );
void withdrawNode( int );
void printNode( int ) const;
void printList() const;
private:
ListNode< typename nodeType >* firstNode;
ListNode< typename nodeType >* lastNode;
//funções utilidade. Será usada somente dentro da classe.
//Promove maior reusabilidade
ListNode< typename nodeType >* allocNode( int, nodeType );
ListNode< typename nodeType >* exists( int ) const;
bool isLastNode( ListNode< typename nodeType >* );
bool isFirstNode( ListNode< typename nodeType >* );
};
#endif
|
List.cpp
1 2 3 4 5 6 7 8 9
|
#include <iostream>
using std :: cout;
using std :: cin;
using std :: endl;
#include "List.h"
member functions defenitions
|
Driver Program
1 2 3 4 5 6 7 8 9
|
#include< iostream >
using std :: cout;
using std :: cin;
using std :: endl;
#include "List.h"
main function and other test functions
|
The code works well if I put all the .cpp and the .h files all together, but otherwise i receive the following messages from the Visual C++ 2008 compiler:
------ Build started: Project: (Template) Lista duplamente encadeada, Configuration: Debug Win32 ------
Compiling...
List.cpp
Linking...
Driver.obj : error LNK2019: unresolved external symbol "public: __thiscall List<float>::~List<float>(void)" (??1?$List@M@@QAE@XZ) referenced in function _main
Driver.obj : error LNK2019: unresolved external symbol "public: void __thiscall List<float>::printNode(int)const " (?printNode@?$List@M@@QBEXH@Z) referenced in function _main
Driver.obj : error LNK2019: unresolved external symbol "public: void __thiscall List<float>::printList(void)const " (?printList@?$List@M@@QBEXXZ) referenced in function _main
Driver.obj : error LNK2019: unresolved external symbol "public: void __thiscall List<float>::withdrawNode(int)" (?withdrawNode@?$List@M@@QAEXH@Z) referenced in function _main
Driver.obj : error LNK2019: unresolved external symbol "public: void __thiscall List<float>::addNode(int,float)" (?addNode@?$List@M@@QAEXHM@Z) referenced in function _main
Driver.obj : error LNK2019: unresolved external symbol "public: __thiscall List<float>::List<float>(void)" (??0?$List@M@@QAE@XZ) referenced in function _main
C:\Documents and Settings\Lucas\Desktop\(Template) Lista duplamente encadeada\Debug\(Template) Lista duplamente encadeada.exe : fatal error LNK1120: 6 unresolved externals
Build log was saved at "file://c:\Documents and Settings\Lucas\Desktop\(Template) Lista duplamente encadeada\(Template) Lista duplamente encadeada\Debug\BuildLog.htm"
(Template) Lista duplamente encadeada - 7 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Thanks