当前位置: 首页 > news >正文

旅游网站html代做百度首页排名价格

旅游网站html,代做百度首页排名价格,有什么做旅游攻略的网站,管理公司网站一般做什么1、类模板 2、使用类模板 类模板在使用的时候要显示的调用是哪种类型&#xff0c;而不是像函数模板一样能够根据参数来推导出是哪种类型。 Stack.h #include <stdexcept>template <typename T> class Stack { public:explicit Stack(int maxSize);~Stack();void …

1、类模板

2、使用类模板

类模板在使用的时候要显示的调用是哪种类型,而不是像函数模板一样能够根据参数来推导出是哪种类型。

Stack.h

#include <stdexcept>template <typename T>
class Stack
{
public:explicit Stack(int maxSize);~Stack();void Push(const T& elem);void Pop();T& Top();const T& Top() const;bool Empty() const;private:T* elems_;int maxSize_;int top_;
};template <typename T>
Stack<T>::Stack(int maxSize) : maxSize_(maxSize), top_(-1)
{elems_ = new T[maxSize_];
}template <typename T>
Stack<T>::~Stack() {delete []elems_;
}template <typename T>
void Stack<T>::Push(const T& elem)
{if (top_ + 1 >= maxSize_){throw std::out_of_range("Stack<T>::Push stack full");}elems_[++top_] = elem;
}template <typename T>
void Stack<T>::Pop()
{if (top_ + 1 <= 0){throw std::out_of_range("Stack<T>::Pop stack empty");}--top_;
}template <typename T>
T& Stack<T>::Top()
{if (top_ + 1 <= 0){throw std::out_of_range("Stack<T>::Top stack empty");}return elems_[top_];
}template <typename T>
const T& Stack<T>::Top() const
{if (top_ + 1 <= 0){throw std::out_of_range("Stack<T>::Top stack empty");}return elems_[top_];
}template <typename T>
bool Stack<T>::Empty() const {return top_ + 1 == 0;
}

main.cpp

#include <iostream>
using namespace std;
#include "Stack.h"
int main() {Stack<int> s(10);s.Push(1);s.Push(2);s.Push(3);while (!s.Empty()){cout << s.Top() << endl;s.Pop();}return 0;
}// 输出
3
2
1

3、非类型模板参数

Stack2.h

#include <stdexcept>template <typename T, int MAX_SIZE>
class Stack2
{
public:Stack2();~Stack2();void Push(const T& elem);void Pop();T& Top();const T& Top() const;bool Empty() const;private:T* elems_;int top_;
};template <typename T, int MAX_SIZE>
Stack2<T, MAX_SIZE>::Stack2() : top_(-1)
{elems_ = new T[MAX_SIZE];
}template <typename T, int MAX_SIZE>
Stack2<T, MAX_SIZE>::~Stack2() {delete []elems_;
}template <typename T, int MAX_SIZE>
void Stack2<T, MAX_SIZE>::Push(const T& elem)
{if (top_ + 1 >= MAX_SIZE){throw std::out_of_range("Stack2<T>::Push stack full");}elems_[++top_] = elem;
}template <typename T, int MAX_SIZE>
void Stack2<T, MAX_SIZE>::Pop()
{if (top_ + 1 <= 0){throw std::out_of_range("Stack2<T>::Pop stack empty");}--top_;
}template <typename T, int MAX_SIZE>
T& Stack2<T, MAX_SIZE>::Top()
{if (top_ + 1 <= 0){throw std::out_of_range("Stack2<T>::Top stack empty");}return elems_[top_];
}template <typename T, int MAX_SIZE>
const T& Stack2<T, MAX_SIZE>::Top() const
{if (top_ + 1 <= 0){throw std::out_of_range("Stack2<T>::Top stack empty");}return elems_[top_];
}template <typename T, int MAX_SIZE>
bool Stack2<T, MAX_SIZE>::Empty() const {return top_ + 1 == 0;
}

main.cpp

#include <iostream>
using namespace std;
#include "Stack2.h"
int main() {Stack2<int, 10> s;s.Push(1);s.Push(2);s.Push(3);while (!s.Empty()){cout << s.Top() << endl;s.Pop();}return 0;
}// 输出
3
2
1
http://www.hkea.cn/news/605157/

相关文章:

  • 网站开发有前途吗我也要投放广告
  • 备案 网站名称怎么写crm软件
  • 扁平式网站模板b2b网站推广优化
  • 做外贸网站网络营销咨询服务
  • 江门网站建设方案报价淘宝seo优化怎么做
  • 盘龙城做网站推广网站推广
  • 如何做电子书网站域名站长工具
  • 物联网平台有哪些排名优化外包公司
  • 秦皇岛汽车网站制作数字营销工具
  • 培训教育的网站怎么做东莞做网站的联系电话
  • 云南做网站的公司外贸谷歌优化
  • 网页设计学徒培训可试学巢湖seo推广
  • 让顾客心动的句子seo模拟点击软件源码
  • 设计类专业包括哪些kj6699的seo综合查询
  • 手机网站制作哪家好查关键词
  • 米拓企业网站管理系统电商培训机构排名前十
  • 做效果图有哪些网站seo点击排名
  • 网络营销推广网站收录seo推广排名平台有哪些
  • 产品经理如何看待网站开发广州软件系统开发seo推广
  • wordpress 忘记管理员如何做网站seo
  • app和网站哪个有优势淘宝关键词排名
  • wordpress该域名宁波网站seo公司
  • 建购物网站怎么建呀简单的网站建设
  • 江苏省建设教育协会网站首页百度知道合伙人答题兼职入口
  • 做优化的网站平台搭建
  • 做网站需要多久网络推广是什么专业
  • 厦门加盟网站建设线上推广营销
  • 定制网站案例seo搜索引擎优化薪酬
  • 网站制作成功后怎么使用浏览器观看b站视频的最佳设置
  • 一家专门做开网店的网站北京seo专员