Hi, i have a problem with compiling these file:
/** @file struct.h */
#ifndef STRUCT_H
#define STRUCT_H
using namespace std;
...
template <typename cStruct> int InitLine(cStruct * toStruct);
template <typename cStruct, typename cItem> int AddToLine(cStruct * toStruct, cItem * newItem);
template <typename cStruct, typename cItem> int DeleteFromLine(cStruct * toStruct, cItem * delItem);
#endif // STRUCT_H
/** @file struct.h */
#ifndef STRUCT_H
#define STRUCT_H
using namespace std;
...
template <typename cStruct> int InitLine(cStruct * toStruct);
template <typename cStruct, typename cItem> int AddToLine(cStruct * toStruct, cItem * newItem);
template <typename cStruct, typename cItem> int DeleteFromLine(cStruct * toStruct, cItem * delItem);
#endif // STRUCT_H
To copy to clipboard, switch view to plain text mode
/** @file struct.cpp */
#include "struct.h"
template <typename cStruct> int InitLine(cStruct * toStruct)
{
toStruct->first=NULL;
toStruct->last=NULL;
toStruct->top=0;
return 0;
}
...
/** @file struct.cpp */
#include "struct.h"
template <typename cStruct> int InitLine(cStruct * toStruct)
{
toStruct->first=NULL;
toStruct->last=NULL;
toStruct->top=0;
return 0;
}
...
To copy to clipboard, switch view to plain text mode
/** @file mainwindow.h */
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "struct.h"
...
#endif // MAINWINDOW_H
/** @file mainwindow.h */
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "struct.h"
...
#endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode
and when i call fnc from mainwindow.cpp
InitLine(NewLine);
InitLine(NewLine);
To copy to clipboard, switch view to plain text mode
the compile output is:
.../mainwindow.cpp:702: undefined reference to `int InitLine<TMyStruct>(TMyStruct*)'
Bookmarks