填空题

下面的函数定义是某函数模板能够生成的函数实例
int square(int n)return n*n;
double square(double n)return n*n;
由此可知,该函数模板的定义是______。

【参考答案】

template(type n)type square(type n){return n*n;)
<上一题 目录 下一题>
热门 试题

填空题
请将下面的程序补充完整,使得程序输出“飘是张娜的书”。 #include<iostream> using namespace std claSS Book public: Book(char*str)| strcpy(title,str); void Printlnfo()cout<<title<<end1; protected: char title[50]; ; class MyBook:public Book public: MyBook(char*s1,char*s2= 张娜 ); ______(strcpy(owner,s2); virtual void Printlnfo()cout<<title<< 是 <<owner<< 的书 <<end1; private: char owner[10]; ; int main() Book *ptr=new MyBook( 飘 ); ptr—>PrintInfo(); return 0;
填空题
在有理数类Rational中重载插入运算符<<,以便按a q形式输出。请将<<运算符函数的定义补充完整。 class Rational public: Rational(int aa,int qq):a(aa),q(qq) friend______operator<<(ostream&out,Rational&x) return(out<<x.a<<’ ’<<x.q); private: int a,q; ;
相关试题
  • 在C++中,cin是一个()。
  • 打开文件时可单独或组合使用下列文件打开模...
  • 数据库设计中,用E-R图来描述信息结构但不...
  • 下列代码段声明了3个类: class Person...
  • 数据库管理系统中负责数据模式定义的语言是...