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 :-) |