I m getting linking errors
like
Dijkstra's error LNK2019: unresolved external symbol "public: __thiscall List<struct Path_store>::List<struct Path_store>(void)" (??0?$List@UPath_store@@@@
QAE@XZ) referenced in function "public: __thiscall Interface::Interface(void)
" (??0Interface@@QAE@XZ)
I m giving my 3 files Interface.h , linklst.cpp and .h file as I think these are related.
Interface.h
#ifndef INTERFACE_H
#define INTERFACE_H
// Header Files
#include "iostream" // Input & Output
#include "stdlib.h" // Use of std lib functions such as exit()
#include "stdio.h" // Use of Input and Output Streams
#include "apvector.h" // Used apvectors in the program
#include "Listlnk.h" // Use of member functions of the list class
using namespace std;
// --------------------------
----------
----------
----------
----------
----------
-
// Structure for the input provided by the user
struct UserInput
{
int vertex_1; // Stores the first vertex
int vertex_2; // Stores the second vertex
int Edge_Len; // stores the length of the edge formed by the
// 2 vertices
};
// --------------------------
----------
----------
----------
----------
----------
-
// Structure for the priority queue of the Dijkstra's Algorithm
struct Prior_Q
{
int vertex ; // Stores the Vertices of the Graph
int Source_Dist; /* Stores the distance of that vertex from the source
vertex initially all but the source = -1.
-1 implies that the cost of path to that vertex
from the source is infinit */
};
// --------------------------
----------
----------
----------
----------
----------
-
// Structure for the Shortest/Min cost Path Storage at a given instance.
struct Path_store
{
int vertex; // Stores the vertex in the sloution set 'S'
int Ver_Dist; // Stores the shortest distance from the source.
apvector<int> path; // Stores the shortest path to this vertex from the
// source
};
//------------------------
----------
----------
----------
----------
----------
----
// Class Interface
class Interface
{
// --------------------------
----------
----------
----------
----------
---------
public:
// Constructor of the class
Interface();
//------------------------
----------
----------
----------
----------
----------
----
// Input Functions
// Store the source and the end destination to the private data members.
void store_source_sink ( int source, int sink);
// Input the graph values
void input_graph(int vert_1, int vert_2, int pathLen);
// Error if same set of vertices is found in the Input List
bool same_vert_error (int vert1, int vert2);
//------------------------
----------
----------
----------
----------
----------
----
// Priority Queue Functions
// Add vertex to priority queue if it does not already exist in the priority
// queue.
void add_to_pqueue(int vert);
// Sort the priority queue according to distance of the vertex from the source
// vertex. A value of -1 implies infinity.
void sort_pqueue_dist();
// Sort the priority the queue according to vertex number
// Adds the vertex at the appropriate place.
void sort_pqueue_vert(Prior_Q &queue);
// Search the priority Q (already sorted) for a certain vertex.
// Leave the cursor at the element if found.
bool search_pqueue_vert(int key_Vert);
// Returns true if the priority queue head position implies
// there is only one element in the p-Queue
bool is_q_at_end();
//Pops the top element of the priority queue
void remove_top( Prior_Q &temp);
// Replaces the distance from the source for the vertex marked by the cursor
void replace_dist_inQ(int dist);
//------------------------
----------
----------
----------
----------
----------
----
// Path Store operations
// Adds a vertex along with its distance from the source and the corresponding
// path to the path storage.
void add_to_path(int vert, int dist, apvector<int> path);
// Searches the passed vertex and return true if it is found in the Path Store
// List
bool searchvert_in_path(int active_vert);
// Add the shortest path for a vertex to the PathStore structure.
void add_shortest_path( int vertex, int Path_Size, apvector<int> path);
// Relax the neighbouring edges and evaluate the distances of the correspoding
// vertex/Ces to the Source.
void relax_edge(int Active_vertex);
//------------------------
----------
----------
----------
----------
----------
----
// Searches for the passsed vertex in the sloution set of the Dijkstra's
// Algorithm
bool searchVertin_solnset(int vert);
//------------------------
----------
----------
----------
----------
----------
----
// Display the output. The path and shortest length
void show_result();
//------------------------
----------
----------
----------
----------
----------
----
private:
// private data members.
int source; // Stores the source vertex while finding the shortest
// path
int sink; // Stores the vertex to which the shortest path from the
// source is intended to.
List<UserInput> input; // Stores the graph vertices along with the
// corresponding edge lengths.
List<Prior_Q> P_Queue; // Stores the priority queue of the Dijkstra's Algorithm
List<Path_store>Path; // Stores the shortest path & the value to a vertex
// from a given source at a given time.
apvector<int> SolnSet; // Stores the vertices already dealt with permanently.
// Stores the solution set of Dijkstra Algorithm.
};
#endif
Linklst.h
#ifndef LISTLNK_H
#define LISTLNK_H
template <class LE>
class List;
template < class LE >
class ListNode // Facilitator class for the List class
{
public:
// Constructor
ListNode ( const LE &elem, ListNode *nextPtr );
// Data members
LE element;
ListNode *next;
friend class List<LE>;
};
//------------------------
----------
----------
----------
----------
----------
----
template <class LE>
class List
{
public:
// Constructor
List ( );
void insert (const LE &newElement ); // Insert after cursor
void remove (); // Remove Element
void replace ( const LE &newElement ); // Replace Element
void clear (); // Clear List
// List status operations
int empty () const; // List is empty
int full () const; // List is full
// List iteration operations
int gotoBeginning (); // Go To Beginning
int gotoEnd (); // Go to End
int gotoNext (); // Go to next element
int gotoPrior (); // Go to prior element
LE getCursor () const; // Return element
int getLength(); // Returns the length of the list
bool isAtEnd () const; // Returns true if the cursor is at
// end of the list
// Output the list structure -- used in testing/debugging
void showStructure () const;
// In-lab oprations
void moveToBeginning () ; // Move to beginning
void insertBefore ( const LE &newElement ); // Insert before cursor
private:
// Data members
ListNode<LE> *head, *cursor; // Pointer to the beginning of the list
// Cursor pointer
friend class Interface;
friend class ListNode<LE>;
};
#endif
linklst.cpp
// Header Files
#include "iostream.h" // Input and Ouput
#include "listlnk.h" // Implementation of the list functions
//------------------------
----------
----------
----------
----------
----------
----
// ListNode Class Constructor
template <class LE>
ListNode<LE>::ListNode ( const LE &elem, ListNode *nextPtr )
{
element = elem;
next = nextPtr;
}
//------------------------
----------
----------
----------
----------
----------
----
// List Class Constructor
template <class LE>
List<LE>:: List ()
{
head = NULL;
cursor = NULL;
}
//------------------------
----------
----------
----------
----------
----------
----
//List class insert function. Inserts after cursor position
template <class LE>
void List<LE> :: insert ( const LE &newElement )
{
if(!full())
{
if(!empty())
{
ListNode<LE> *temp1;
temp1 = cursor;
cursor = new ListNode<LE>( newElement, cursor->next);
temp1->next = cursor;
}
else
{
cursor = new ListNode<LE> ( newElement, NULL);
head = cursor;
}
}
}//end of void
//------------------------
----------
----------
----------
----------
----------
----
// List class remove function. remove element marked by cursor
template <class LE>
void List<LE> :: remove ()
{
if(!empty())
{
ListNode<LE> *temp1;
temp1 = head;
if( head != cursor )
{
while(temp1->next != cursor)
temp1 = temp1->next;
temp1->next = cursor->next;
temp1 = cursor;
if( cursor ->next !=NULL)
cursor = cursor -> next;
else
cursor = head;
delete [ ] temp1;
}
else
if( cursor->next == NULL )
{
temp1 = cursor;
cursor = NULL;
head = NULL;
delete [ ] temp1;
}
else
if( cursor->next != NULL)
{
temp1 = head;
head = head->next;
cursor = head;
delete temp1;
}
}
};
//------------------------
----------
----------
----------
----------
----------
----
// List class replace function . replaces the element marked by the cursor
template <class LE>
void List<LE>::replace( const LE &newElement )
{
if ( ! empty ( ) )
{
cursor->element = newElement;
}
}
//------------------------
----------
----------
----------
----------
----------
----
// List class clear function. Clears the list
template<class LE>
void List<LE>::clear( )
{
cursor = head;
while ( cursor !=NULL )
{
head = cursor->next;
delete [ ] cursor;
cursor = head;
}
}//end of void
//------------------------
----------
----------
----------
----------
----------
----
// List class empty status function
template <class LE>
int List<LE> :: empty ( ) const
{
if ( cursor == NULL ) // returns if 1 empty
return 1;
else
return 0;
}
//------------------------
----------
----------
----------
----------
----------
----
// List class full status function
template <class LE>
int List<LE>::full ( ) const
{
ListNode<LE> *temp;
if( temp == NULL )
return 1; // returns 1 is full
else
return 0; // returns 0 otherwise
}
//------------------------
----------
----------
----------
----------
----------
----
// List class go to Begin function. Cursor moves to the beginning
template <class LE>
int List<LE>::gotoBeginning ()
{
if(! empty ())
{
cursor = head;
return 1;
}
else
{
return 0;
}
}
//------------------------
----------
----------
----------
----------
----------
----
// List class go to end function. Cursor moves to the end of the list
template <class LE>
int List<LE>::gotoEnd ()
{
if(! empty () )
{
while (cursor->next != NULL)
cursor = cursor->next;
return 1;
}
else
{
return 0;
}
}
//------------------------
----------
----------
----------
----------
----------
----
// List class to go Next function Cursor moves to the next element in the list
template <class LE>
int List<LE>::gotoNext ()
{
if(!empty ())
{
if(cursor->next !=NULL)
{
cursor = cursor->next;
return 1;
}
else
{
return 0;
}
}
else
{
return 0;
}
}
//------------------------
----------
----------
----------
----------
----------
----
// List class getcursor for Returns the element marked by the cursor
template <class LE>
LE List<LE>::getCursor () const
{
if(!empty ())
{
return cursor->element;
}
}
//------------------------
----------
----------
----------
----------
----------
----
// List class goto Prior function Cursor moves to the prior element
template <class LE>
int List<LE>::gotoPrior ()
{
if(!empty() && head!=cursor )
{
ListNode<LE> * temp;
temp = head;
while(temp->next != cursor)
temp = temp->next;
cursor = temp;
return 1;
}
else
{
return 0;
}
}
//------------------------
----------
----------
----------
----------
----------
----
template <class LE>
void List<LE>::showStructure () const
// Outputs the elements in a list. If the list is empty , outputs
// "Empty List". This operation is intended for testing and debugging purpose only
{
ListNode<LE> *p; // Interface through the list
if ( head == 0 )
cout << "Empty list" << endl;
else
{
for( p = head; p!= 0; p = p->next )
if ( p == cursor )
cout << "[" << p->element << "] ";
else
cout << p->element << " ";
cout << endl;
}
}
//------------------------
----------
----------
----------
----------
----------
----
// Returns the number of nodes in the linked list.
template <class LE>
int List<LE>::getLength()
{
if(empty())
return 0;
else
{
ListNode<LE> *temp;
temp = cursor;
int i = gotoBeginning();
int count = 1;
while( cursor->next !=NULL)
{
cursor = cursor->next;
count++;
}
cursor = temp;
return count;
}
}
//------------------------
----------
----------
----------
----------
----------
----
// List class insertbefore function. Inserts a new node before the position
// marked by the cursor.
template <class LE>
void List<LE>::insertBefore ( const LE &newElement )
{
if(!full())
{
if(!empty() && head != cursor)
{
ListNode<LE> *temp;
temp = head;
while( temp->next != cursor)
temp = temp->next;
cursor = new ListNode<LE> ( newElement, cursor)
temp->next = cursor;
}
else
{
cursor = new ListNode<LE> ( newElement, cursor);
head = cursor;
}
}
}
//------------------------
----------
----------
----------
----------
----------
----
// Returns true if the cursor is at the end of the list else returns false
template <class LE>
bool List<LE>::isAtEnd() const
{
if(!empty())
{
if( cursor->next == NULL)
return true;
else
return false;
}
return false;
}
What can be the reason calling this linking problem....
I need help on this problem immediately...I m doing a mesh project in the uni which is due soon and I m stuck on this linker error
Regards
Harsimrat