H
Hukkky
File : NodeList.h
//----------------------------------------------------------------------
#ifndef NODELIST_H
#define NODELIST_H
#include <string>
using std::string;
template <typename T>
class NodeList
{
public:
class Node
{
public:
Node* itsPrev;
Node* itsNext;
T* itsData;
};
public:
NodeList();
Node* SearchStr( string myStr );
private:
Node* itsHeader;
Node* itsTrailer;
};
#endif
---------------------------------------------------------
NodeList.cpp
//---------------------------------------------
#include "NodeList.h"
template<typename T>
NodeList<T>::NodeList()
{
size = 0;
this->itsHeader = new Node;
this->itsTrailer = new Node;
this->itsHeader->itsNext = this->itsTrailer;
this->itsTrailer->itsPrev = this->itsHeader;
}
template<typename T>
Node* NodeList<T>::SearchStr( string myStr )
{
//for test
return NULL;
}
//-------------------------------------
----------------------- complie message----------------
1>Compiling...
1>nodelist.cpp
1>d:\play ground\oop2 lec workspace
\e_library_test_2\e_library_test_2\nodelist.cpp(33) : error C2143:
syntax error : missing ';' before '*'
1>d:\play ground\oop2 lec workspace
\e_library_test_2\e_library_test_2\nodelist.cpp(33) : error C4430:
missing type specifier - int assumed. Note: C++ does not support
default-int
1>d:\play ground\oop2 lec workspace
\e_library_test_2\e_library_test_2\nodelist.cpp(33) : error C2065:
'T' : undeclared identifier
1>Build log was saved at "file://d:\Play Ground\OOP2 Lec Workspace
\e_library_test_2\e_library_test_2\Debug\BuildLog.htm"
1>e_library_test_2 - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========
//----------------------------------------------------------------------
#ifndef NODELIST_H
#define NODELIST_H
#include <string>
using std::string;
template <typename T>
class NodeList
{
public:
class Node
{
public:
Node* itsPrev;
Node* itsNext;
T* itsData;
};
public:
NodeList();
Node* SearchStr( string myStr );
private:
Node* itsHeader;
Node* itsTrailer;
};
#endif
---------------------------------------------------------
NodeList.cpp
//---------------------------------------------
#include "NodeList.h"
template<typename T>
NodeList<T>::NodeList()
{
size = 0;
this->itsHeader = new Node;
this->itsTrailer = new Node;
this->itsHeader->itsNext = this->itsTrailer;
this->itsTrailer->itsPrev = this->itsHeader;
}
template<typename T>
Node* NodeList<T>::SearchStr( string myStr )
{
//for test
return NULL;
}
//-------------------------------------
----------------------- complie message----------------
1>Compiling...
1>nodelist.cpp
1>d:\play ground\oop2 lec workspace
\e_library_test_2\e_library_test_2\nodelist.cpp(33) : error C2143:
syntax error : missing ';' before '*'
1>d:\play ground\oop2 lec workspace
\e_library_test_2\e_library_test_2\nodelist.cpp(33) : error C4430:
missing type specifier - int assumed. Note: C++ does not support
default-int
1>d:\play ground\oop2 lec workspace
\e_library_test_2\e_library_test_2\nodelist.cpp(33) : error C2065:
'T' : undeclared identifier
1>Build log was saved at "file://d:\Play Ground\OOP2 Lec Workspace
\e_library_test_2\e_library_test_2\Debug\BuildLog.htm"
1>e_library_test_2 - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========