摘要
栈作为一种后进先出结构,在程序设计中广泛使用。类模板是C++所提供的一种占有重要地位的特殊机制,能根据不同参数建立不同类型对象的类。通过类模板建立通用栈类,栈中便可以存放任意类型的数据,提高编程效率,增强软件通用性和灵活性。简要介绍了栈的概念和C++的模板类的定义和使用,并利用模板类实现了通用的栈结构,还给出了在Visual C++环境使用的实例。
As a LIFO structure ,stack is widely used in program design. Template class, a kind of important special mechanism provided by C ++, can create objects of different types according to the different parameters of the class.After created into general stack by template class ,the stack can store any type of data, improve the efficiency of programming, enhance the software flexibility and generality.This paper introduces the concept of stack and how to use the template class of C++ simply, achieves a general stack by using template class, and gives a instance using template class in visual C++.
出处
《电脑开发与应用》
2013年第11期66-69,共4页
Computer Development & Applications
关键词
栈
模板类
C++
通用栈
stack, template class, C++, general stack