| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 418 人关注过本帖
标题:简单template 的问题
只看楼主 加入收藏
HGC2006
Rank: 1
等 级:新手上路
帖 子:122
专家分:0
注 册:2006-7-31
收藏
 问题点数:0 回复次数:2 
简单template 的问题
#include <iostream.h>
template <class T>
void printArray(const T *array, const int count);
{// 错误信息出现在这边
for (int i = 0; i<count; i++)
cout<<array[i]<<" ";
cout<<endl;
}
int main(){
const int aCount =5,bCount = 7,cCount = 6;
int a[aCount] = {1,2,3,4,5};
double b[bCount] = {1.1,2.2,3.3,4.4,5.5,6.6,7.7};
char c[cCount] = "HELLO";
cout<<"Array a contains";
printArray (a,aCount);
cout<<"Array b contains";
printArray(b,bCount);
cout<<"Array c contains";
printArray(c,cCount);
return 0;
}
C:\Documents and Settings\People\tmpla.cpp(4) : error C2447: missing function header (old-style formal list?)
谢谢了
搜索更多相关主题的帖子: template 
2007-11-07 15:38
随心
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:12
帖 子:2577
专家分:250
注 册:2007-8-12
收藏
得分:0 
以下是引用HGC2006在2007-11-7 15:38:06的发言:
#include <iostream.h>
template <class T>
void printArray(const T *array, const int count);//这里多了个分号
{// 错误信息出现在这边
for (int i = 0; i<count; i++)
cout<<array[i]<<" ";
cout<<endl;
}
int main(){
const int aCount =5,bCount = 7,cCount = 6;
int a[aCount] = {1,2,3,4,5};
double b[bCount] = {1.1,2.2,3.3,4.4,5.5,6.6,7.7};
char c[cCount] = "HELLO";
cout<<"Array a contains";
printArray (a,aCount);
cout<<"Array b contains";
printArray(b,bCount);
cout<<"Array c contains";
printArray(c,cCount);
return 0;
}
C:\Documents and Settings\People\tmpla.cpp(4) : error C2447: missing function header (old-style formal list?)
谢谢了


天之道,利而不害。圣人之道,为而不争。信言不美,美言不信。善者不辩,辩者不善。知者不博,博者不知。
2007-11-07 15:43
HGC2006
Rank: 1
等 级:新手上路
帖 子:122
专家分:0
注 册:2006-7-31
收藏
得分:0 
谢了 

如果世界都是好人,那要警察干嘛?
2007-11-07 15:44
快速回复:简单template 的问题
数据加载中...
 
   



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

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