| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 472 人关注过本帖
标题:[求助][求助]HELP
只看楼主 加入收藏
wangleier
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2005-10-19
收藏
 问题点数:0 回复次数:2 
[求助][求助]HELP

我用C++builder6.0编程如下
#include <iostream.h>
#include <vcl.h>
#pragma hdrstop
#include <conio.h>
#pragma argsused
template <class T>
class Array
{
protected:
T* date;
int base;
int length;
public:
Array();
Array(unsigned int,unsigned int=0);


Array(Array const&);
Array& operator=(Array const&);

T const& operator[](unsigned int)const;
T& operator[](unsigned int);

T const* Date()const;
unsigned int Base()const;
unsigned int Length()const;

void SetBase(unsigned int);
void SetLength(unsigned int);
};
template<class T>
Array<T>::Array():
data(new T[n]),base(0),length(0)
{}
template<class T>
Array<T>::Array(unsigned int n,unsigned int m):
date(new T[n]),base(m),length(n)
{}
template<class T>
T const* Array<T>::Date () const
{return date;}
template<class T>
unsigned int Array<T>::Base()const
{return base;}
template<class T>
unsigned int Array<T>::Length()const
{return length;}
template <class T>
Array<T>::Array (Array<T> const& array):
date(new T[array.length]),
base(array.base),
length(array.length)
{
for (unsigned int i=0;i<length;++i)
date[i]=array.date[i];
}
template <class T>
Array<T>& Array<T>::operator = (Array<T> const& array)
{
if (this!=&array)
{
delete [] date;
base=array.base;
length=array.length;
date=new T[length];
for (unsigned int i=0;i<length;++i)
date[i]=array.date[i];
}
return *this;
}
template <class T>
T const& Array<T>::operator[](unsigned int position) const
{
unsigned int const offset=position-base;

return date[offset];
}
//---------------------------------------------------------------------------


int main(int i,int j)
{ int const* p;
Array<int> intArr(4,8);
i=intArr.Base();
p=intArr.Date();
for(j=4;j<12;++j)
intArr[j]=j;
cout<<*p;
getch();
return 0;
发生错误如下[Linker Error] Unresolved external 'Array<int>::operator [](unsigned int)' referenced from E:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\DATE.OBJ

搜索更多相关主题的帖子: HELP 
2005-11-09 12:14
zinking
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:35
帖 子:916
专家分:0
注 册:2004-12-5
收藏
得分:0 

连接错误的话。看一下自己的头文件包含什么的有没有出错

暂时也没空帮你改!


http://kongfuziandlife. http://codeanddesign.
2005-11-09 12:50
RL720
Rank: 1
等 级:新手上路
帖 子:148
专家分:0
注 册:2005-11-6
收藏
得分:0 
#include <vcl.h>是什么东西啊~
用MSDN都查不到~


2005-11-09 18:41
快速回复:[求助][求助]HELP
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.036531 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved