template<template typename tT> int cmp_EN(T *p1,T *p2) { return p1->get_EN()>p2->get_EN(); } 这样

#include&iostream.h& #include&math.h& template&typename T& T calculateDistance(T x1,T y1,T x2,T y2)_百度知道
#include&iostream.h& #include&math.h& template&typename T& T calculateDistance(T x1,T y1,T x2,T y2)
这个是哪里错了啊 求指教
怎么把多个文件放到一个工程里面呢
速回 拜托了
cout&lt,d;a&&gt,T y1;T calculateDistance(T x1.h&quot,c;&calculateDistance(a;&lt.h&&lt,T x2,d)&}void main(){
cin&#include&&gt,T y2){
return(sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)),b,b;b&d;template&c&typename T&&gt,c刚才代码没发上去 不好意思哦#include&quot
提问者采纳
cpp&#47。多个文件放到一个过程里的方法有很多:Source Files&#47,至少你给的这部分没错。还有一种办法就是打开工程的“工作区间”在FileView里面有三个栏目.h);Resource Files,最直接的办法就是在同一个工程里新建多个文件(,所以什么错误看不出来;Header
Files/因为看不到你的完整的程序
error C2958: the left parenthesis '(' found at 'c:\documents and settings\admin\桌面\cpp1.cpp(6)' was not matched correctly执行 cl.exe 时出错.把这个程序放进VC编译器里会提示这个错误还有就是那个文件添加进去以后相互中间的引用怎么完成呢
你这个错误是指类型不匹配。sqrt返回类型是double,但是T被指定为了int,所以出错。改正办法是将a,b,c,d的类型都改为double型。至于互相引用,只要在同一个工程里,.cpp之间是相互可见的,不需要include语句什么,只有头文件(.h)需要include包含。如果想用不同.cpp中的变量,函数,需要用extern语句声明这个变量或者函数来自于本工程的不同cpp文件。
提问者评价
编写一个求两点距离的函数,并给出三种以上的重载形式如果有时间能否帮忙变一下这个呢非常感谢
其他类似问题
typename的相关知识
其他1条回答
么把多个文件放到一个工程里面呢 :把文件保存,答案!点一下小剪刀就行啦
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁求用c++编的图书信息管理系统做参考?_百度知道
求用c++编的图书信息管理系统做参考?
包括记录的追加和插入;
2、信息删除、简单的帮助包含
4、信息排序和查询、信息录入;
6、信息修改、信息的保存和装载
我有更好的答案
按默认排序
Cnext=GetItemname()&&void Chain&/Code&/typename T&读者姓名;endl:;T&gt: Code&void Chain&lt.GetName();B
return NULL!&删除节点 int Length();
p=p-&class Data{&lt!&
cout&lt.h&/#include &quot:;T&&lt.h&&#47.h&GetLibname()&没有要删除的节点;&data);&quot: I获取图书名 char *GetAuthor();条码号 char EnterNumber[20]!=*d; Code(T d);头插入{ Code&;: friend class Chain&
if(p1==NULL)
cout&/T&gt,int d){ year=y:Insert(T d)/T& void Display();\template&// L}#pragma once#include &#include &链表为空:; Code(){} *Seek(T d);链表为空;T&gt:&#include &/ char *GetReadercode();// cout&lt:Display()/ } else
if(*(p1-&获取图书作者名 void DelOnjia(); *p1;T&gt.SName()==*d;/next:GetReadername(){char *BDtypename T&
if(p==NULL)
cout& *Chain&I/
if(p==NULL)
cout&data);没有信息&#92.h&&记录节点个数{ int l=0; D'(d):;T&#include &&#39.GetTitle();&/ Rtypename T& cout&& } else {
if(*(p-& month=m,无节点可删;/Dn&登录号 char Press[20];&C T data.h&分类号 char BarCode[20]!=NULL&&*(p-&D
delete p1; p=typename T&&&&T&iostream&& cout&next!&quot.GetName(); }查找链表中的数据 void DelCode(T d);T&iostream&gt:GetReadercode(){&&lt!=NULL&&*(p1-&}; char *GetReadername():;删除节点成功: Bookborrow(){} char *SName();}template&
(p-&gt,图书类{typename T&&&&lt::Getlist(){ if(p==NULL) {
cout&/Code&}void B&using namespace std.SName();
} }}template&/n操作员姓名;T&&lt!&
while(p1:;#include &&lt:DelCode(T d)/册数 int O char *GetItemname();T&}char *Bnext=p1-&gt.SName())
list=p1-&typename T&借书时间;; void Display():: while(p) {
l++;出版社 Data PublishDfstream&
}}#pragma once template&lt!&quot:GetItemname(){
return p.h&quot.SName()==*d;};&作者名 char IndexCode[20];template&lt:!& next=0;}#pragma once#include&&Onjia+1 int GetOnjia():Code(T d){ data=d: char *GetTitle(); p1=p2=list,int m=0:;&;typename T&/template&lt.h&quot.SName())
delete p1;&class Chain{T&void Chain&/&&/T&
while(p; void GetData();出版时间 double P#include&typename T&/ *p;
p=p-&#include&lt:Length()&#47:Seek(T d){ Code&/} void Insert(T d);'&lt,int d=0): Chain(void){ list=0.GetTitle():;/&template&lt.h&/} Chain(T d){ list=new Code& Code&lt.SName())&&lt.h& p-&
p2-&&&T& *Getlist(); *p:&quot:&(d);p1=p1-&#include&GetReadercode()&lt: char Title[20]; class C&/ if(list==NULL) {
cout&lt.Display();/R;T&typename T&gt:Data(T& *Chain& char *GetLibname(); GetData();&T&/T&读者图书证编号;头插入 void Display();year&&}char *B/&#47:GetData(){&&#47.h&书名 char Author[20].SName();
p=list,day.SName())
p2=p1:;}char *B#include&价格 int N Code& *end()::Display(){ cout&lt:Display(){ cout&输出链表内容 Code&/&lt:SName(){class Item/Code&//}void DL;T&//&#include&&data);;class Bookborrow{ *p=new Code&&/iomanip&}template&T&/iostream&&;
cout&&&#47,string&gt:&month&获取图书册数 char *SName();#include&I/& day=d;n&#92:; */T&gt: Data(int y=0;endl&}#pragma once#include& *记录节点个数 Code&GetReadername()&/&next!=*d;&quot: Code&;&using namespace std.Display();&};&}template&}void BD书名;&lt:;}char *B#include&&/typename T&
return NULL;/ list=p.GetCode();int Chain&T&&&输出链表内容{
Code&删除节点成功:; cout&};data);;' *p=/&删除节点{
Code&data);/
}}template&/要查询的数据不在此链表中:GetLibname(){ return manager,*p2;Onjia-1 void AddOnjia();&在架数& void Display();class Code{public#pragma once#include & Item(){}}; void SetData():&quot
不急的话 明天给你 急的话 有个类似的学生管理系统可以给你参考
其他类似问题
信息管理系统的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁数据结构与算法的问题_百度知道
数据结构与算法的问题
并删除老数组一,将表中元素复制到新数组中,类似地;2maxsize的新数组.设表的Reverse运算将表中元素的次序反转,并删除老数组.
用上述思想重新设计用数组实现表的结构
二,在删除一个元素后,就重新分配一个大小为1&#47,其后在插入一个元素时,就重新分配一个大小为2*maxsize的数组,如果表已满,如果表的大小已降至1&#47.用数组实现表的一个缺点是需要预先估计表的大小,将表中的元素复制到新数组只能感.
扩充用数组实现表的结构L4maxsize,克服这个缺点的一个方法是在初始化时先将数组大小maxsize置为1,增加函数Rverse(L)将表L中元素的次序反转
提问者采纳
; T GetData(const int poistition); bool ShrinkSpace();class T& try { newspace = new T[nim].;count || position &lt.; } catch(; } if(position& } template&lt:ShrinkSpace() { if (max& } template &lt.; for(int i= List *p3 = p2-&gt.Reverse();class T&gt:;=count/d=falsestruct List { 0) T tb&lt:AddData(const T dt: bool AddData(const T } d[position]=&&i++) { int p =class T&gt:; } int pos=0;0) max--;class T& }.0;T&\T& } } catch(.) { &#39:; i--) { d[i]=d[i+1].GetData(i),max))]; p2 = p3 ; List *p1 = bool DataMove();2; } template&lt, char* argv[]) { tb& } return DataMove().; } int main(T& } while(getchar());; } d= class tb { T&class T&gt: /i&i++) { i& } i++) { int temp=d[i];=pos:DataMove() { try { if(d) { for(int i=1:ExpandSpace() { max++; template&:DeteleData(const int position) { if(count==pow(2;UserInterFace BEGIN;&next = p1 ;count || position & count++;next = NULL ; head = p2 ; d[i]=d[count-i]; bool Reverse();; bool ExpandSpace();
cout& } int&next ,const int position) { if(count==pow(2;i&lt:Reverse() { try { for(int i=0; } count--; }; if(position==0) pos=count-1; bool tb&&lt:template &T& bool tb& bool tb&ExpandSpace();i--) { d[i+1]=d[i];/ bool tb&lt: T *d; else return false,const int position);count ||position&int& List *p2 = p1-&UserInterFace END;=10; }
p1 = p2 ;p&lt.) { return false,max-1)) { if(ShrinkSpace(); for(int i=2;0) T *i&count=0; } template&T&gt.; for(int i=} / cout& int nim=static_cast& private,1)& else pos=position.AddData(i:,max));=10;/ p3 = p3-&gt!=true) if(position& i& while ( p3 .) { (pow(2; }或者这样吧;; p1-& for(int i=1;class T&class T& } delete[] bool tb&; } template&&t&#39:; bool DeteleData(const int position).) { int&:; else return *(d+position-1);;i&T& bool tb&=count!= NULL ) { p2-& } catch(;next = p1 ;0) return *d!=true) return false:GetData(const int position) { if(position&class T&gt,max)) { if(ExpandSpace(); d[count-i]=&(pow(2;=position.; } return DataMove():;i&& try { newspace = new T[static_cast&
typedef struct List L } template & } p2-&gt.;i++) { newspace[i-1]=d[i-1]; List * } catch(; tb(int maxp=1) {max=next == NULL )
List * ReverseList(List *head) { if ( head == NULL || head-& return 0; return true
其他类似问题
您可能关注的推广
数据结构与算法的相关知识
其他3条回答
链表逆序{if ( head == NULL || head-&next = p1 ;}p2-&next == NULL )return head、struct List{List *p3 = p2-&List *p2 = p1-&next 2;p3 = p3-&while ( p3 ;List *};typedef struct List Lnext = p1 != NULL ){p2-&List * ReverseList(List *head) /List *p1 =p1-&next = NULL ;p1 = p2 ;p2 = p3 ;head = p2 ;&#47
DEVC++中调试通过。VC6对范型支持不好。使用的时候看好下标,由于俺完美的把下表定义为自然数列,所以导致第一个元素混乱,我整半天了尚未发现原因,你从第2个下标开始使用就行。。。。继续debuging中。。。你是应用,还是考题。应用的话,建议你用个class,一部分是指向下一个对象的指针,另一部分是数据。在初始化时,建立数组,可以有效的节省数据移动的时间,并可以用while(n=n/2){...}的类似形式选取对象。就是数据域不定的链表了,哈哈。//#include &stdafx.h&#include &iostream.h&#include &stdio.h&#include &math.h&template &class T& class tb{public:
//UserInterFace BEGIN:bool AddData(const T dt,const int position); bool DeteleData(const int position); T GetData(const int poistition);
bool Reverse(); tb(int maxp=1) {max=d=ExpandSpace();count=0;}
//UserInterFace END;private:
bool ExpandSpace();
bool ShrinkSpace();
bool DataMove();};template&class T& bool tb&T&::ExpandSpace(){ max++; int nim=static_cast&int&(pow(2.0,max)); try {
newspace = new T[nim]; } catch(...) { }
return DataMove(); }template&class T& bool tb&T&::ShrinkSpace(){ if (max&0) max--; try {
newspace = new T[static_cast&int&(pow(2,max))]; } catch(...) { }
return DataMove();}template&class T& bool tb&T&::DataMove(){ try { if(d) {
for(int i=1;i&=i++)
newspace[i-1]=d[i-1];
delete[] }
d= } catch(...) { }}template&class T& bool tb&T&::AddData(const T dt,const int position){
if(count==pow(2,max)) {
if(ExpandSpace()!=true)
}int pos=0;
if(position==0) pos=count-1;
if(position&count || position &0)
for(int i=i&=i--)
d[i+1]=d[i];
d[position]=}template&class T& bool tb&T&::DeteleData(const int position){ if(count==pow(2,max-1)) {
if(ShrinkSpace()!=true) } if(position&count || position &0)for(int i=i&=i--)
d[i]=d[i+1];
count--;}template &class T& T tb&T&::GetData(const int position){ if(position&count ||position&0) return *d; else
return *(d+position-1);}template &class T& bool tb&T&::Reverse(){ try { for(int i=0;i&=count/2;i++) {
int temp=d[i];
d[i]=d[count-i];
d[count-i]= } } catch(...) { }}int main(int argc, char* argv[]){ tb&int&
for(int i=1;i&=10;i++) {
cout&&lp.AddData(i,1)&& }
lp.Reverse(); for(int i=2;i&=10;i++) {
int p = lp.GetData(i);
cout&&i&&'\t'&&p&& }
while(getchar()); return 0;}
你使用链表撒?
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁TutorialsBASH ShellTroubleshootingNginxNetworkingMySQLGoogle Cloud PlatformAmazon Cloud ComputingRackspace Cloud ComputingLinuxCentOSDebian / UbuntuUbuntu LinuxSuseRedHat and FriendsSlackware LinuxUNIXAIXMac OS XFreeBSDFreeBSD Jails (VPS)OpenbsdSolarisSee all tutorial topicsContact usForumLinux Scripting GuideRSS/FEEDShopLinux FAQ / HowtosQ. Can you give me example for If else statement in C Program under Linux or TC?A. C follows universal syntax for if..else. You can use any complier GNU Linux gcc or UNIX or old good TC.if..else syntaxGeneral if..else syntax is as follows:if ( condition ) {
expr_set1;
expr_set2;
}If given condition is TRUE, expr_set1 will get executed. If given condition is FALSE (not TRUE), expr_set2 will get executed.if..else exampleFollowing example will find out large number from given input:#include&stdio.h&
int main(){
printf("Enter value for x :");
scanf("%d",&x);
printf("Enter value for y :");
scanf("%d",&y);
if ( x & y ){
printf("X is large number - %d\n",x);
printf("Y is large number - %d\n",y);
return <font color="#;
Tweet itFacebook itG+ itDownload PDF version Featured Articles:30 Cool Open Source Software I Discovered in 2013 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS XTop 30 Nmap Command Examples For Sys/Network Admins25 PHP Security Best Practices For Sys Admins20 Linux System Monitoring Tools Every SysAdmin Should Know20 Linux Server Hardening Security TipsLinux: 20 Iptables Examples For New SysAdminsTop 20 OpenSSH Server Best Security Practices Top 20 Nginx WebServer Best Security Practices20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors15 Greatest Open Source Terminal Applications Of 2012My 10 UNIX Command Line MistakesTop 10 Open Source Web-Based Project Management SoftwareTop 5 Email Client For Linux, Mac OS X, and Windows UsersThe Novice Guide To Buying A Linux Laptop Leave a Comment Subscribe to nixCraftLearn something new about Linux/Unix by emailEnter your email address:
Latest posts from our blogA Shell Primer: Master Your Linux, OS X, Unix Shell Environment7 Awesome Open Source Cloud Storage Software For Your Privacy and Security20 Unix Command Line Tricks – Part I5 Awesome Open Source Backup Software For Linux and Unix-like Systems8 Tips to Solve Linux & Unix Systems Hard Disk Problems Like Disk Full Or Can’t Write to the Disk

我要回帖

更多关于 template typename 的文章

 

随机推荐