由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - a c++ question for template
相关主题
recursive template?django admin style sheets
[合集] 关于template和inheritance的问题请教请问const myClass &src 和myClass const &src有什么区别?
师傅们,C++概念题,弟子有礼了问几个C++面试题吧
What're the three types of memory allocated for C++ variables?C++0x
也问个template 的问题(C++)如何 define/initialize static data member of a class templ
为什么要用templatec++ template是不是跟Macro一个道理?
question on template and inheritance?一个 C++ STL base type 的问题
a careercup question[合集] 又被羞辱了一把... (转载)
相关话题的讨论汇总
话题: linkage话题: choice话题: templates话题: macros话题: static
进入Programming版参与讨论
1 (共1页)
n*****r
发帖数: 159
1
Templates are often thought to be very similar to C-style macros. Which
one of the following statements about templates is true?
Choice 1 Macros have static linkage; templates have external linkage.
Choice 2 Templates are strongly typed; macros are not.
Choice 3 Macros are evaluated at compile time; templates are at runtime.
Choice 4 Class templates are less efficient than class macros.
Choice 5 You can inherit from a macro.
I know 1,3 is not correct. How about 2,4,5?
p*u
发帖数: 2454
2
i think 1 and 2 are correct, unless it's a template function with internal l
inkage.
4 is vague, define "efficient" first.

【在 n*****r 的大作中提到】
: Templates are often thought to be very similar to C-style macros. Which
: one of the following statements about templates is true?
: Choice 1 Macros have static linkage; templates have external linkage.
: Choice 2 Templates are strongly typed; macros are not.
: Choice 3 Macros are evaluated at compile time; templates are at runtime.
: Choice 4 Class templates are less efficient than class macros.
: Choice 5 You can inherit from a macro.
: I know 1,3 is not correct. How about 2,4,5?

k****f
发帖数: 3794
3
第一个是什么意思?静态链接?

l

【在 p*u 的大作中提到】
: i think 1 and 2 are correct, unless it's a template function with internal l
: inkage.
: 4 is vague, define "efficient" first.

n*****r
发帖数: 159
4
I searched c++ standard and found no definition of static linkage, so choice
1 may not be correct. For choice 4, if efficient means run-time cost (
calling overhead, storage, et al.),
Is it correct?

l

【在 p*u 的大作中提到】
: i think 1 and 2 are correct, unless it's a template function with internal l
: inkage.
: 4 is vague, define "efficient" first.

p*u
发帖数: 2454
5

choice
~~~~~~~~~~~~~~~~~~what's ur logic here?
I don't think it's correct.

【在 n*****r 的大作中提到】
: I searched c++ standard and found no definition of static linkage, so choice
: 1 may not be correct. For choice 4, if efficient means run-time cost (
: calling overhead, storage, et al.),
: Is it correct?
:
: l

N*********y
发帖数: 105
6
Agree, 4 should not be correct. For 1, is macro static linkage if static
linkage is what we understand?

【在 p*u 的大作中提到】
:
: choice
: ~~~~~~~~~~~~~~~~~~what's ur logic here?
: I don't think it's correct.

t****t
发帖数: 6806
7
there is no "static linkage". there's only 3 types of linkage: external,
internal and no linkage. external linkage object can be referred in other
translation units, internal linkage can be referred in the same translation
unit but in different scope, no linkage can't be referred outside the scope.
whatever static linkage is, both template and macro can be external or
internal linkage. mixing macro and linkage are vague and not strict anyway,
since macros are not seen by compilers at all.

【在 N*********y 的大作中提到】
: Agree, 4 should not be correct. For 1, is macro static linkage if static
: linkage is what we understand?

N*********y
发帖数: 105
8
mostly I agree with you. I would assume static linkage is meant to be
internal linkage here, considering the meaning of "static" keywords.

translation
scope.
,

【在 t****t 的大作中提到】
: there is no "static linkage". there's only 3 types of linkage: external,
: internal and no linkage. external linkage object can be referred in other
: translation units, internal linkage can be referred in the same translation
: unit but in different scope, no linkage can't be referred outside the scope.
: whatever static linkage is, both template and macro can be external or
: internal linkage. mixing macro and linkage are vague and not strict anyway,
: since macros are not seen by compilers at all.

w**s
发帖数: 1911
9
2
1 (共1页)
进入Programming版参与讨论
相关主题
[合集] 又被羞辱了一把... (转载)也问个template 的问题(C++)
Default function template arguments为什么要用template
C++ template problemquestion on template and inheritance?
一个C++ template的问题a careercup question
recursive template?django admin style sheets
[合集] 关于template和inheritance的问题请教请问const myClass &src 和myClass const &src有什么区别?
师傅们,C++概念题,弟子有礼了问几个C++面试题吧
What're the three types of memory allocated for C++ variables?C++0x
相关话题的讨论汇总
话题: linkage话题: choice话题: templates话题: macros话题: static