开发者社区> 问答> 正文

编译程序出现 error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏 -服务报错

错误 1 error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏 C:\Users\Administrator\desktop\数据结构实验\LAB1_1\LAB1_1\LINK




使用软件   Microsoft Visual Studio 2010


代码:


//SqList.h


#ifndef SQLIST_H
#define SQLIST_H




template <class elemType>
class SqList
{
private:
int count;     
int maxSize;   
elemType &elem;
public:
SqList(int size);
virtual ~SqList();
SqList(SqList <elemType>©);
bool empty();
int Length();
void clear();
bool getElem(int position,elemType &e);
bool setElem(int position,elemType &e);
bool Delete(int position,elemType &e);
bool insert(int position,elemType &e);
};




#endif







//SqList.cpp


#include"SqList.h"
#include<iostream>
using namespace std;




template<class elemType>
SqList<elemType>::SqList(int size)
{
maxSize=size;
elem=new elemType[maxSize];
count=0;
}




template<class elemType>
SqList<elemType>::~SqList()
{
delete[] elem;
}




template<class elemType>
SqList<elemType>::SqList(SqList <elemType>©)
{
maxSize=copy.maxSize;
elem=new elemType[maxSize];
cout=copy.count;




for(int pos;pos<=Length();pos++)
{
elem[pos-1]=copy.elem[pos-1];
}
}




template<class elemType>
bool SqList<elemType>::empty()
{
return count==0;
}




template<class elemType>
int SqList<elemType>::Length()
{
return count;
}




template<class elemType>
void SqList<elemType>::clear()
{
count=0;
}




template<class elemType>
bool SqList<elemType>::getElem(int position,elemType &e)
{
if(position<1||position>Length())
{
return false;
}
else
{
e=elem[position-1];
return true;
}
}




template<class elemType>
bool SqList<elemType>::Delete(int position,elemType &e)
{
elemType tmp;
if(position<1||position>Length())
{
return false;
}
else
{
getElem(position,e);
for(int pos=position+1;pos<=Length();pos++)
{
getElem(pos,tmp);
setElem(pos-1,tmp);
}
count--;
return true;
}
}




template<class elemType>
bool SqList<elemType>::setElem(int position,elemType &e)
{
if(position<1||position>Length())
{
return false;
}
else
{
elem[position-1]=e;
return true;
}
}




template<class elemType>
bool SqList<elemType>::insert(int position,elemType &e)
{
elemType tmp;;
if(count==maxSize)
{
return false;
}




else if(position<1||position>Length()+1)
{
return false;
}




else
{
for(int pos=Length();pos>=position;pos--)
{
getElem(pos,tmp);
setElem(pos+1,tmp);
}




setElem(position,e);
count++;
return true;
}
}






//main.cpp


#include "SqList.h"
#include <iostream>
using namespace std;




int main()
{
int R;
int arr[]={21,23,14,5,56,17,31};
SqList<int> list(10);
for(int pos=0;pos<7;pos++)             //输入元素
{
list.setElem(pos,arr[pos]);
}




for(int pos=0;pos<=list.Length();pos++)
{
list.getElem(pos,R);
cout<<"线性表原有元素:"<<R<<"  ";
}
cout<<endl;


}

展开
收起
montos 2020-05-31 15:22:33 467 0
1 条回答
写回答
取消 提交回答
  • http://blog.csdn.net/rryr2/article/details/8221357

    这种问题以后问百度就行了 不要我们帮你百度

    ######很简单可以排查 你把你的代码全删掉 换个helloworld试试 如果helloworld都不行那就不是代码问题了######关键是我机子里面就只有vs2010,没有vs2008,而且第二种配置属性的我试过,会出现更多的错误...能不能帮我看看是不是我写的程序某个位置出错了,谢谢######http://bbs.csdn.net/topics/390121452?page=1#post-395715556这个一定能帮到你
    2020-05-31 15:22:46
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载