unresolved externals
哪里有错误呢?怎么老是通不过?
///头文件stackhpp.h
template <class Type>
class Stack{
public:
Stack(int s);
~Stack();
void push(Type &item);
void pop();
Type top();
bool empty() const;
bool isfull() const;
private:
const int maxstack;
int count;
Type* stack;
};
////实现文件stackhpp.cpp
#include "stdafx.h"
#include "stackhpp.h"
#include<iostream>
#include"process.h"
using namespace std;
template <class Type>
Stack<Type>::Stack(int s)
{
maxstack=s;
Type*element=new Type[maxstack];
count=0;
}
template <class Type>
Stack<Type>::~Stack()
{
delete []element;
}
template <class Type>
void Stack<Type>::push(Type &item)
{
if(count>=maxstack){
cout<<"can not push.";
exit(1);
}
else
element[count++]=item;
}
template <class Type>
void Stack<Type>::pop()
{
if(count==0)
cout<<"can not pop.";
else
count--;
}
template <class Type>
Type Stack<Type>::top()
{
if(count==0)
cout<<"no elemenet.";
else
return element[count-1];
}
template <class Type>
bool Stack<Type>::empty() const
{
if(count==0)
return true;
else
return false;
}
template <class Type>
bool Stack<Type>::isfull() const
{
if(count==maxstack)
return true;
else
return false;
}
////主函数
// stack22.cpp : 定义控制台应用程序的入口点。
//
//#include "stdafx.h"
#include "stackhpp.h"
int main()
{
Stack <int> aaa(5);
return 0;
}
///头文件stackhpp.h
template <class Type>
class Stack{
public:
Stack(int s);
~Stack();
void push(Type &item);
void pop();
Type top();
bool empty() const;
bool isfull() const;
private:
const int maxstack;
int count;
Type* stack;
};
////实现文件stackhpp.cpp
#include "stdafx.h"
#include "stackhpp.h"
#include<iostream>
#include"process.h"
using namespace std;
template <class Type>
Stack<Type>::Stack(int s)
{
maxstack=s;
Type*element=new Type[maxstack];
count=0;
}
template <class Type>
Stack<Type>::~Stack()
{
delete []element;
}
template <class Type>
void Stack<Type>::push(Type &item)
{
if(count>=maxstack){
cout<<"can not push.";
exit(1);
}
else
element[count++]=item;
}
template <class Type>
void Stack<Type>::pop()
{
if(count==0)
cout<<"can not pop.";
else
count--;
}
template <class Type>
Type Stack<Type>::top()
{
if(count==0)
cout<<"no elemenet.";
else
return element[count-1];
}
template <class Type>
bool Stack<Type>::empty() const
{
if(count==0)
return true;
else
return false;
}
template <class Type>
bool Stack<Type>::isfull() const
{
if(count==maxstack)
return true;
else
return false;
}
////主函数
// stack22.cpp : 定义控制台应用程序的入口点。
//
//#include "stdafx.h"
#include "stackhpp.h"
int main()
{
Stack <int> aaa(5);
return 0;
}
...全文
相关推荐
visual c++出错:unresolved externals 执行 link.exe 时出错.
发现编译没问题,组建就报错 1.看看有没有对应的库,即没有相应的lib文件 2.创建时选择的是不是Win32Application 3.第一次使用,系统会呆呆的,重新创建一个把代码复制粘贴上去就OK了 4.说明你的程序正在运行或 前一次运行关闭不正常,窗口虽然消失了但是进程还在,用任务管理器结束它即可。由于你前一次调试运行是最后没有按任意键退出程序,而是点“关闭”按钮关 cmd窗口的,窗口被关闭了但是程序进程还在运行. 因此可以试试重新启动VC. 5.解决的办法是关闭软件,然后以管理员权限运行该软件,这样就可以完美运行调试程序了。 6.放在C盘,不要把程序放到C盘里 7.找个好点的资源卸载后
MFC 1 unresolved external
MFC 1 unresolved external MFC 1 unresolved external MFC 1 unresolved external MFC 1 unresolved external
(Win7_+_OpenCV1.0_+_VC++6.0)配置
Win732位 OpenCV1.0 VC++6.0的配置,希望有用!
vc中error LNK2001 resolved external symbol _WinMain@16的解决方法
阐述了C++中vc中error LNK2001 resolved external symbol _WinMain@16的解决方法的解决方法。
VS下LUA编程环境搭建
VS下LUA编程环境搭建,doc文件,按图索骥式学习


