- 浏览: 400942 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (309)
- xaml C# wpf (0)
- scala java inner clas (1)
- Tools UML Eclipse UML2 (1)
- Timer .NET Framework (1)
- perl (6)
- python function paramter (1)
- Python Docstring (1)
- Python how to compare types (1)
- Python (8)
- java (5)
- C# (76)
- C# WPF (0)
- p4 (0)
- WPF (46)
- .net (6)
- xaml (1)
- javascript (40)
- windows (10)
- scala (4)
- winform (1)
- c++ (48)
- tools (12)
- cmd (1)
- os (0)
- CI (0)
- shell (0)
- C (2)
- haskell (49)
- functional (1)
- tool (1)
- gnu (1)
- linux (1)
- kaskell (0)
- svn (0)
- wcf (3)
- android (1)
最新评论
the template has parameter, it can contains type paramter and it can also have nontype paramter, in the following code.
template <class Type, int size> class Buffer;
the class template buffer has two paramter, one is the non-determinic parameter, which is Type, and one nontype (which means the type itself is bound and known, which remains unknown is only the vlaue of the nontype parameter).
As for the function parameter, you can also provide default value for template class, for the type paramter, the default value is type, while for the non-type parameter, the default value is value.
Let's see the example below.
/** * file: * default_template_parameters.h * * description: * this file shows that you can provide default paramter value for either the type parameter or the nontype parameter */ #include<string> using std::string; template <class Type, int size = 1024> class Buffer; template <class Type = string, int size /* you don't need to provide "= 1024" */> class Buffer; //template <class Type = string, int size = 1024> //class Buffer; template <class Type, int size> class Buffer { public: Buffer() : _size(size) {} private: Type elem; int _size; protected: };
发表评论
-
不安装Visual Studio,只用Windows SDK搭建VC环境
2013-12-31 21:52 15345首先你需要下载的是 Microsoft Windows S ... -
rpath - runtime search path
2013-04-03 11:36 1019RPath is a very interesting to ... -
C++ - autogenerated copy constructor and assignment operator gotchas
2013-01-24 13:32 773It has been changed that the s ... -
c++ - rethrow a exception gotchas
2012-12-23 10:57 972As in my prevoius example in j ... -
c++ -typeid operator
2012-10-15 22:30 1065typeid is the one of the meager ... -
c++ - dynamic_cast revisit
2012-10-14 21:21 781There are several built-in type ... -
c++ - virtual inheritance example 1
2012-10-14 15:25 830we have discussed the virtual i ... -
c++ - virtual inheritance
2012-10-12 08:58 992As we have discussed in the pos ... -
c++ type of inheritance
2012-09-28 08:58 755There are 3 types of inheritanc ... -
c++ - vritually virtual new
2012-09-27 23:59 961Let's see what if we want to cl ... -
c++ - virtual destructor
2012-09-27 22:01 981As we all know that virtual des ... -
c++ - vritual function and default arguments
2012-09-27 08:56 1000As we all know that we virtual ... -
c++ - template specialization and partial specialization
2012-09-26 22:38 1335in this post, we are going to e ... -
c++ - member template in class template
2012-09-26 08:19 944class member template can be us ... -
c++ template class and the pattern to use its friends
2012-09-25 23:47 991template class may defined thei ... -
c++ - Friend declaration in class Template
2012-09-25 08:47 1214There are three kinds of friend ... -
c++ - operator new and delete and an example of linked list stores by new/delete
2012-09-24 07:53 594The operator new and delete ope ... -
c++ - delete(void *, size_t) or delete(void *)
2012-09-24 07:18 1173In my previous dicuss, we have ... -
c++ - placement operator new() and the operator delete()
2012-09-23 15:22 877A class member operator new() c ... -
c++ - overloaded subscript operator - []
2012-09-23 08:50 1194You can overload the subscript ...
相关推荐
- **Class Template Argument Deduction:** Use CTAD (Class Template Argument Deduction) to make template class instantiation more concise. - **Designated Initializers:** Use designated initializers for ...
* During Dev-C++ First Time COnfiguration window, users can now choose between using or not class browser and code completion features. * Many bug fixes Version 4.9.8.4 * Added the possibility to ...
- 类模板:`template<typename T> class ClassName { ... };` 3. **Lambda 表达式**: - 匿名函数:`[]() { ... };` 4. **类型推断**: - `auto` 关键字用于自动类型推断 5. **范围 for 循环**: - `for ...
Other C++ Features Reference Arguments Function Overloading Default Arguments Variable-Length Arrays and alloca() Friends Exceptions Run-Time Type Information (RTTI) Casting Streams Preincrement and ...
- **Template Class stack:** Explains template classes with an example of a stack. - **Function Templates:** Describes function templates. - **Generic Code Development: Quicksort:** Provides a generic ...
This chapter covers the Standard Template Library (STL), a powerful set of C++ libraries: - **STL Containers**: Explanation of STL containers, such as vectors, lists, and maps. - **STL Algorithms**: ...
- `default`: 在开关语句中表示默认情况。 - `goto`: 无条件跳转到标记的位置。 - `sizeof`: 返回数据类型的大小(字节数)。 - `volatile`: 表示变量可能被意外地改变。 - `do`: 循环结构的关键字,先执行后判断。 ...
RSP-29256 Compiler generates wrong code for template function RSP-29227 Incorrect property value obtained from the record RSP-29226 Access violation with working code under 10.2 RSP-29218 compiling ...
- FIX: The TFlexPanel.FPaintCache field moved in the protected class section. Added rcPaint field in FPaintCache that represents drawing rectangle. - ADD: In the text prcise mode (TFlexText.Precise=...
declare non-member functions when type conversions should apply to all parameters. 条款25:考虑写出一个不抛异常的swap函数 consider support for a non-throwing swap. 5. 实现 implementations 条款26:尽...
根据给定的C++错误提示英汉对照表,我们可以详细解析并总结出一系列与C++编程相关的常见错误及其解决方法,这对于理解和调试C++代码至关重要。 1. **Ambiguous operators need parentheses** - 模糊的操作符需要...
3. **默认参数(Default Parameters)**:函数可以有默认参数,如`void testDefaulParam(int a, int b=7, char z='*')`,调用时如果省略了参数,会使用默认值。 4. **重载函数(Overload Function)**:重载函数...
4.4 The C++ memory model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 4.5 The C++ object model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...
组态10:default template argument depend on previous template parameters 030 组态11:non-type template parameters 031 组态:bound friend template function 032 组态:class template explicit ...
33)..Changed: Default template of HTML/web dialog now includes call stack by default 34)..Changed: EurekaLog 7 now can be installed over EurekaLog 6 automatically, with no additional actions/tools ...
组态10:default template argument depend on previous template parameters 030 组态11:non-type template parameters 031 组态:bound friend template function 032 组态:class template explicit ...
2.2.1 Default Configuration and Images ................................................................. 8 2.2.2 Configuration With VxWorks Image Projects ................................................