R
Rechtfertigung
Guest
I got a LNK2019 error in my program. Most of the time it's because I failed to define a function in my .cpp file. but I checked all my functions and they are defined.
error: Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: __thiscall ArrayStackModel<int>::ArrayStackModel<int>(int)" (??0?$ArrayStackModel@H@@QAE@H@Z) referenced in function _main ArrayStack
ArrayStackModel.h
template <typename dataType>
class ArrayStackModel
{
public:
int maxSize = 0; // a varaible that is used to set inital size of array. set to 0 to avoid garbage value
int currSize = 0; //current size of the stack p.s use this as a reference to build your stack
int const minSize = 0; //minSize will be used to determine if the stack is empty
ArrayStackModel(int stackSize); //Constructor that builds the base of the stack using an array and take a param to make the original size
void Push(dataType value); // add new item of dataType to the stack. Param: value to be added
void Pop(); // takes last item added to stack and removes it *(pops it)* remember LIFO
void Peek(); // sees inside the stack and displays its elements
bool IsEmpty(); // checks to see if the stack is empty
};
ArrayStackModel.cpp
template<typename dataType>
ArrayStackModel<dataType>::ArrayStackModel(int stackSize)
{
ArrayStackModel::maxValue = stackSize;
dataType a[ArrayStackModel::maxValue] = 0;
}
template<typename dataType>
void ArrayStackModel<dataType>:ush(dataType value)
{
a[ArrayStackModel::currSize] = value;
ArrayStackModel::currSize++;
}
template<typename dataType>
void ArrayStackModel<dataType>:op()
{
if (currSize <= 0)
{
std::cout << "There are no elements to pop"
}
else
{
a[ArrayStackModel::currSize - 1] = 0;
}
}
template<typename dataType>
void ArrayStackModel<dataType>:eek()
{
if (currSize <= 0)
{
std::cout << "There are no elements in this stack"
}
else
for (int i = maxSize; i < currSize -1; i++)
{
cout << "Stack contains: " << a << endl;
}
}
template<typename dataType>
bool ArrayStackModel<dataType>::IsEmpty()
{
if (currSize <= 0)
{
return false;
}
else
return true;
}
Recht
Continue reading...
error: Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: __thiscall ArrayStackModel<int>::ArrayStackModel<int>(int)" (??0?$ArrayStackModel@H@@QAE@H@Z) referenced in function _main ArrayStack
ArrayStackModel.h
template <typename dataType>
class ArrayStackModel
{
public:
int maxSize = 0; // a varaible that is used to set inital size of array. set to 0 to avoid garbage value
int currSize = 0; //current size of the stack p.s use this as a reference to build your stack
int const minSize = 0; //minSize will be used to determine if the stack is empty
ArrayStackModel(int stackSize); //Constructor that builds the base of the stack using an array and take a param to make the original size
void Push(dataType value); // add new item of dataType to the stack. Param: value to be added
void Pop(); // takes last item added to stack and removes it *(pops it)* remember LIFO
void Peek(); // sees inside the stack and displays its elements
bool IsEmpty(); // checks to see if the stack is empty
};
ArrayStackModel.cpp
template<typename dataType>
ArrayStackModel<dataType>::ArrayStackModel(int stackSize)
{
ArrayStackModel::maxValue = stackSize;
dataType a[ArrayStackModel::maxValue] = 0;
}
template<typename dataType>
void ArrayStackModel<dataType>:ush(dataType value)
{
a[ArrayStackModel::currSize] = value;
ArrayStackModel::currSize++;
}
template<typename dataType>
void ArrayStackModel<dataType>:op()
{
if (currSize <= 0)
{
std::cout << "There are no elements to pop"
}
else
{
a[ArrayStackModel::currSize - 1] = 0;
}
}
template<typename dataType>
void ArrayStackModel<dataType>:eek()
{
if (currSize <= 0)
{
std::cout << "There are no elements in this stack"
}
else
for (int i = maxSize; i < currSize -1; i++)
{
cout << "Stack contains: " << a << endl;
}
}
template<typename dataType>
bool ArrayStackModel<dataType>::IsEmpty()
{
if (currSize <= 0)
{
return false;
}
else
return true;
}
Recht
Continue reading...