由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - C++ question
相关主题
Help: Another C++ compilation error on GCCtail call strange behavior on cl.exe
C arrayprivate destructor
有谁知道怎么把matlab和VC联接着一起用? (转载)求GCC高手
C++ help: 一个multiple definition problem.Eclipse JNI问题, 拜谢
在 windows下的C++开发平台是不是 Dev-C++?C++ Boost怎么样,好用吗?
面试被问到G++和GCC编译器的关系How to use volatile in c++?
问个虚函数的作用A C++ compiler related interview question
[合集] a C++ template question (code inside)面试题还是不太清楚怎么回答。尤其是8,我用MSVC试了一下,没有问题啊。
相关话题的讨论汇总
话题: choice话题: c++话题: cannot话题: union
进入Programming版参与讨论
1 (共1页)
T*****J
发帖数: 193
1
1.
我选3, 但2的说法可以吗?
With regard to virtual functions, which one of the following statements is
true?
Choice 1
They cannot be used in template classes.
Choice 2
They facilitate polymorphism.
Choice 3
They cannot be inlined.
Choice 4
They facilitate delegation.
Choice 5
They cannot be used in structures.
2. 选 HandleNoMemory() is never called. 对吗?
void HandleNoMemory();
int main(){
int * p = new int[100];
if(!p)
{
HandleNoMemory();
}
return 0;
}
Ref
X****r
发帖数: 3557
2
A virtual function can be inline if it is resolved statically instead
of dynamically.

is

【在 T*****J 的大作中提到】
: 1.
: 我选3, 但2的说法可以吗?
: With regard to virtual functions, which one of the following statements is
: true?
: Choice 1
: They cannot be used in template classes.
: Choice 2
: They facilitate polymorphism.
: Choice 3
: They cannot be inlined.

T*****J
发帖数: 193
3
right, thanks a lot!

【在 X****r 的大作中提到】
: A virtual function can be inline if it is resolved statically instead
: of dynamically.
:
: is

a****l
发帖数: 8211
4
Q2 Choice2: seems to be the least "wrong" one.

【在 T*****J 的大作中提到】
: 1.
: 我选3, 但2的说法可以吗?
: With regard to virtual functions, which one of the following statements is
: true?
: Choice 1
: They cannot be used in template classes.
: Choice 2
: They facilitate polymorphism.
: Choice 3
: They cannot be inlined.

d****p
发帖数: 685
5
I got compilation error for the following boost file:
boost/algorithm/string/detail/classification.hpp
Error: FIXED_STORAGE_SIZE is not accessible from union m_Storage
template
struct is_any_ofF :
...public predicate_facade >
{
private:
...static const ::std::size_t FIXED_STORAGE_SIZE = ...
...
private:
...union
...{
......set_value_type m_fixSet[FIXED_STORAGE_SIZE];
...} m_Storage;
...
}
I only encountered the above error on Solaris Sun C++ compiler; GCC and
mi
X****r
发帖数: 3557
6
I think boost and gcc/MSVC are correct. From the C++ standard draft:
9.5 unions [class.union]
2 A union of the form
union { member-specification } ;
is called an anonymous union; it defines an unnamed object of unnamed
type. The member-specification of an anonymous union shall only
define non-static data members. [Note: nested types and functions
cannot be declared within an anonymous union. ] The names of the mem-
bers of an anonymous union shall be distinct fr

【在 d****p 的大作中提到】
: I got compilation error for the following boost file:
: boost/algorithm/string/detail/classification.hpp
: Error: FIXED_STORAGE_SIZE is not accessible from union m_Storage
: template
: struct is_any_ofF :
: ...public predicate_facade >
: {
: private:
: ...static const ::std::size_t FIXED_STORAGE_SIZE = ...
: ...

d****p
发帖数: 685
7
Thanks for help. So I kind of think Solaris C++ compiler is not perfectly C+
+ compliant to support BOOST - I already turned stl4port option on.
I googled this issue but could not find any helpful clues. Maybe the
compiler I was using is not up to date (SunOS C++ 5.5).
Now it seems GCC is the ideal compiler in term of C++ standard compliance.
VC++ compiler is way not too slack while the solaris one too harsh. But
regarding code optimization and compilation speed, GCC sucks :-(
When developing cr

【在 X****r 的大作中提到】
: I think boost and gcc/MSVC are correct. From the C++ standard draft:
: 9.5 unions [class.union]
: 2 A union of the form
: union { member-specification } ;
: is called an anonymous union; it defines an unnamed object of unnamed
: type. The member-specification of an anonymous union shall only
: define non-static data members. [Note: nested types and functions
: cannot be declared within an anonymous union. ] The names of the mem-
: bers of an anonymous union shall be distinct fr

d****p
发帖数: 685
8
Found another Sun machine with Sun OS C++ compiler 5.8 and recompiled with
stlport4 option and the code passed :-)
1 (共1页)
进入Programming版参与讨论
相关主题
面试题还是不太清楚怎么回答。尤其是8,我用MSVC试了一下,没有问题啊。在 windows下的C++开发平台是不是 Dev-C++?
Do the two statements cost the same amount of time?面试被问到G++和GCC编译器的关系
[合集] 大拿们,问一个redhat linux下C编程 make error 139的问问个虚函数的作用
一道c++的考古题[合集] a C++ template question (code inside)
Help: Another C++ compilation error on GCCtail call strange behavior on cl.exe
C arrayprivate destructor
有谁知道怎么把matlab和VC联接着一起用? (转载)求GCC高手
C++ help: 一个multiple definition problem.Eclipse JNI问题, 拜谢
相关话题的讨论汇总
话题: choice话题: c++话题: cannot话题: union