由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - c++里 这个template的写法是什么意思?
相关主题
请教,c++ primer plus是要先看完再刷题吗?一个C语言概念题
C++ Singleton的实现这种牛逼的写法是实现Map接口的匿名内部类吗?
C++非面试题:怎么得到明天的日期?A家2次电面
static initialization dependency c++ (转载)请教一个storage class的问题
弱问C++里NEW的一个语法问题,转行的人伤不起啊。。有熟悉Java Reflection的吗?
c++最变态的是 头文件,模板,const, static 这几件事情。请教个C++编程思路
One C++ question问道编程题
谁给改一个线程安全的smarter pointer类C/C++ Questions
相关话题的讨论汇总
话题: template话题: c++话题: class话题: 意思话题: parameters
进入JobHunting版参与讨论
1 (共1页)
h**********y
发帖数: 1293
1
template
这个template是什么意思?
我google不出来。。。
s**x
发帖数: 7506
2
you need to read the C++ book, any online C++ tutorial should cover this.
this is as basic as keyword class.
J*****a
发帖数: 4262
3
c++叫模板 java叫泛型
任何c++的书上都有的
l*********8
发帖数: 4642
4
这个用法类似于
template < class T, size_t N >
class array {
..
}
http://www.cplusplus.com/reference/array/array/
第二个template参数t有缺省值

【在 h**********y 的大作中提到】
: template
: 这个template是什么意思?
: 我google不出来。。。

h**********y
发帖数: 1293
5
template我知道。。
我说的是这句话
template

【在 s**x 的大作中提到】
: you need to read the C++ book, any online C++ tutorial should cover this.
: this is as basic as keyword class.

h**********y
发帖数: 1293
6
template
class A
{
private:
template
class B
{
public:
static const int m_n = b ? 1 : 0;
};
public:
static const int m_value = B<(t > T())>::m_n - B<(t < T())>::m_n;
};
这个 t到底是什么东西。。

【在 l*********8 的大作中提到】
: 这个用法类似于
: template < class T, size_t N >
: class array {
: ..
: }
: http://www.cplusplus.com/reference/array/array/
: 第二个template参数t有缺省值

n*****u
发帖数: 465
7
t 是 T 的 instance.

【在 h**********y 的大作中提到】
: template
: class A
: {
: private:
: template
: class B
: {
: public:
: static const int m_n = b ? 1 : 0;
: };

l*********8
发帖数: 4642
8
你是不明白语法? 还是不明白这段程序的意义?
从语法上来说, There are three kinds of template parameters:
Type template parameters (C++ only)
Non-type template parameters (C++ only)
Template template parameters (C++ only)
https://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%
2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Ftemplate_arguments.htm

【在 h**********y 的大作中提到】
: template
: class A
: {
: private:
: template
: class B
: {
: public:
: static const int m_n = b ? 1 : 0;
: };

h**********y
发帖数: 1293
9
不明白语法,
后面的B<(t > T())>::m_n
t>T() 是什么意思?比较?

【在 l*********8 的大作中提到】
: 你是不明白语法? 还是不明白这段程序的意义?
: 从语法上来说, There are three kinds of template parameters:
: Type template parameters (C++ only)
: Non-type template parameters (C++ only)
: Template template parameters (C++ only)
: https://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%
: 2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Ftemplate_arguments.htm

l*********8
发帖数: 4642
10
是比较。 得到一个bool值,作为B的template的参数输入。

【在 h**********y 的大作中提到】
: 不明白语法,
: 后面的B<(t > T())>::m_n
: t>T() 是什么意思?比较?

1 (共1页)
进入JobHunting版参与讨论
相关主题
C/C++ Questions弱问C++里NEW的一个语法问题,转行的人伤不起啊。。
一个电面c++最变态的是 头文件,模板,const, static 这几件事情。
bloomberg 第一轮电话面试 电经One C++ question
请教一个C/C++问题谁给改一个线程安全的smarter pointer类
请教,c++ primer plus是要先看完再刷题吗?一个C语言概念题
C++ Singleton的实现这种牛逼的写法是实现Map接口的匿名内部类吗?
C++非面试题:怎么得到明天的日期?A家2次电面
static initialization dependency c++ (转载)请教一个storage class的问题
相关话题的讨论汇总
话题: template话题: c++话题: class话题: 意思话题: parameters