我在用devcpp创建一个栈类时出现了一下错误
1.点全部重新编译时:
2.点编译运行时:
测试.cpp:
#include<bits/stdc++.h>
#include <ctime>
#include <vector>
#include <winsock2.h>
#include<windows.h>
#include<time.h>
#include <fstream>
#include <direct.h>
#include <io.h>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <tchar.h>
#include <string>
#include <string.h>
//#include"2aê?.cpp"
#include <stdlib.h>
#include <Nb30.h>
#include <time.h>
#include <nb30.h>
#include<tchar.h>
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <Iphlpapi.h>
#include <stdio.h>
#include<conio.h>
#include<typeinfo>
#pragma comment(lib, "netapi32.lib")
#pragma comment(lib, "Netapi32.lib")
#define _CRT_SECURE_NO_DEPRECATE
#include "xstack.h"
using namespace std;
using std::cout; using std::cin;
using std::endl; using std::string;
int main()
{
string n="123456";
XStack<string> a("Ss");
a.push(n);
}
xstack.h:
#pragma once
#include<bits/stdc++.h>
#include <ctime>
#include <vector>
#include <winsock2.h>
#include<windows.h>
#include<time.h>
#include <fstream>
#include <direct.h>
#include <io.h>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <tchar.h>
#include <string>
#include <string.h>
//#include"2aê?.cpp"
#include <stdlib.h>
#include <Nb30.h>
#include <time.h>
#include <nb30.h>
#include<tchar.h>
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <Iphlpapi.h>
#include <stdio.h>
#include<conio.h>
#pragma comment(lib, "netapi32.lib")
#pragma comment(lib, "Netapi32.lib")
#define _CRT_SECURE_NO_DEPRECATE
using namespace std;
#ifndef XSTACK_H
#define XSTACK_H
typedef unsigned long long int ulli;//y
template <typename T>
class XStack
{
private:
string mainzs[100000000];//Ss
ulli mainzi[100000000];//y
char mainzc[100000000];//c
long double mainzd[100000000];//e
char *type;
ulli n=1;
public:
int pop()
{
if(n==1)
{
return -1;
}
else
{
this->n--;
}
}
int pop(T& n)
{
char *ch=const_cast<char *>(typeid(n).name());
if(this->type=="")
{
this->type=ch;
}
if(n==1)
{
return -1;
}
else
{
this->n--;
if(this->type=="Ss")
{
}
}
}
int push(T n)
{
char *ch=const_cast<char *>(typeid(n).name());
if(this->type=="")
{
this->type=ch;
}
if(type==ch)
{
this->n++;
if(this->type=="Ss")
{
this->mainzs[this->n]=(string)n;
}
else if(this->type=="y")
{
this->mainzi[this->n]=n;
}
else if(this->type=="c")
{
this->mainzc[this->n]=n;
}
else if(this->type=="e")
{
this->mainzd[this->n]=n;
}
return 1;
}
else
{
return -1;
}
}
bool isfull()
{
ulli temp=100000000-1;
if(n==temp)
{
return true;
}
return false;
}
bool isempty()
{
if(n==1)
{
return true;
}
return false;
}
T top()
{
switch(type)
{
case "Ss" :
return mainzs[n];
case "y" :
return mainzi[n];
case "c" :
return mainzc[n];
case "e" :
return mainzd[n];
}
}
int size() {return n;}
XStack()
{
}
XStack(string type)
{
if(type!="c"||type!="Ss"||type!="y"||type!="e")
{
throw "第一个参数不是指定的参数值 The first parameter is not the specified parameter value";
}
else
{
this->type=const_cast<char *>(type.c_str());
}
}
XStack(string type,T values[],int len)
{
if(type!="c"||type!="Ss"||type!="y"||type!="e")
{
throw "第一个参数不是指定的参数值 The first parameter is not the specified parameter value";
}
else
{
this->type=type.c_str();
for(int i=1;i<=len;i++)
{
this->push(values[i]);
}
}
}
~XStack()
{
}
};
#endif