function template

简介: function template
/*
  function template
  programmer:qpz
*/
#include <iostream>
using namespace std;
template <class T>
class Myclass{
private:
  T x,y;
public:
  Myclass(T x,T y)
  {
    this->x=x;
    this->y=y;
  }
  T Max()
  {
    return x>y?x:y;
  }
};
int main(void)
{
//  Myclass s1(1,2.3); 错误申明
    Myclass <int> s1(1,2);
  cout<<s1.Max()<<endl;
  return 0;
}
相关文章
|
3月前
|
JavaScript
Vue报错 Invalid default value for prop “list“: Props with type Object/Array must use a factory
Vue报错 Invalid default value for prop “list“: Props with type Object/Array must use a factory
71 0
Vue3报错:Extraneous non-props attributes (style) were passed to component but could not be automatical
Vue3报错:Extraneous non-props attributes (style) were passed to component but could not be automatical
2023 1
|
3月前
|
JavaScript 前端开发
[Vue Router warn]: Component “default“ in record with path “/xx“ is a function that does not return
[Vue Router warn]: Component “default“ in record with path “/xx“ is a function that does not return
157 0
|
3月前
|
JavaScript
Property 'xx' does not exist on type 'Element | Element[] | Vue | Vue[]'
Property 'xx' does not exist on type 'Element | Element[] | Vue | Vue[]'
|
8月前
|
JavaScript 前端开发
成功解决Component template should contain exactly one root element
成功解决Component template should contain exactly one root element
|
JavaScript
Vue 报错Failed to mount component: template or render function not defined
Vue 报错Failed to mount component: template or render function not defined
Vue 报错Failed to mount component: template or render function not defined
|
10月前
|
存储 编译器 C++
【C++模板】——template
【C++模板】——template
|
JavaScript
uniapp:[Vue warn]: Failed to mount component: template or render function not de
uniapp:[Vue warn]: Failed to mount component: template or render function not de
158 0
uniapp:[Vue warn]: Failed to mount component: template or render function not de
|
JavaScript
Vue报错:error Elements in iteration expect to have ‘v-bind:key‘ directives vue/require-v-for-key
Vue报错:error Elements in iteration expect to have ‘v-bind:key‘ directives vue/require-v-for-key
380 0
|
JavaScript
Property 'xx' does not exist on type 'Element | Element[ ] | Vue | Vue[ ]'
Vue2.6 + TypeScript3.4 项目中使用 this.$refs.fileInput.files.length 报错,提示 files 类型不存在 Property 'files' does not exist on type 'Element | Element[] | Vue | Vue[]',在不使用TypeScript时上面的写法可以正常运行的,但是这样的写法在TypeScript 中会报错。
Property 'xx' does not exist on type 'Element | Element[ ] | Vue | Vue[ ]'