紧急求助,c++问题,编译老是出错啊

来源:百度知道 编辑:UC知道 时间:2024/09/21 00:28:03
#include <iostream>
#include <fstream> // file I/O suppport
#include <cstdlib> // support for exit()
#include<string>
using namespace std;
struct box
{
char maker[40];
float height;
float width;
float length;
float volume;
};

template<class T>
T largest(T a, T b);

template<>
char* largest(box &b1, box &b2);

int main()
{
int a=3,b=5;
cout<<"3,5最大:"<<largest(a,b)<<endl;
double i=3.5,j=1.2;
cout<<"3.5,1.2最大:"<<largest(i,j)<<endl;

box b1={"b1",2,3,4,24};
box b2={"b2",3,3,2,18};

cout<<largest(b1,b2)<<"体积最大"<<endl;

return 0;
}

template<>
char * largest<box>(box &b1,box &b2)
{
if(b1.volume >b2.volume )
return

#include <iostream>

#include <fstream>          // file I/O suppport

#include <cstdlib>          // support for exit()

#include<string>

using namespace std;

struct box

{

 char maker[40];

 float height;

 float width;

 float length;

 float volume;

};

template<class T>

T largest(T a, T b);

//template<>

char* largest(box &b1, box &b2);

int main()

{

 int a=3,b=5;

 cout<<"3,5最大:"<<largest(a,b)<<endl;

 double i=3.5,j=1.2;

 cout<<"3.5,1.2最大:"<<largest(i,j)<<endl;