Can you think of a situation where your program would
crash without reaching the breakpoint which you set at the beginning of
main()?
Ans- C++ allows for dynamic initialization of global variables before main() is invoked. It is possible that initialization of global will invoke some function. If this function crashes the crash will occur before main() is entered.
Name two cases where you MUST use initialization list as opposed to assignment in constructors.
Ans- Both non-static const data members and reference data members cannot be assigned values; instead, you should use initialization list to initialize them.
Can you overload a function based only on whether a parameter is a value or a reference?
Ans- No. Passing by value and by reference looks identical to the caller.
What are the differences between a C++ struct and C++ class?
Ans- The default member and base class access specifiers are different.
The C++ struct has all the features of the class. The only differences are that a struct defaults to public member access and public base class inheritance, and a class defaults to the private access specifier and private base class inheritance.
What does extern "C" int func(int *, Foo) accomplish?
Ans- It will turn off "name mangling" for func so that one can link to code compiled by a C compiler.
How do you access the static member of a class?
Ans- <ClassName>::<StaticMemberName>
Ans- C++ allows for dynamic initialization of global variables before main() is invoked. It is possible that initialization of global will invoke some function. If this function crashes the crash will occur before main() is entered.
Name two cases where you MUST use initialization list as opposed to assignment in constructors.
Ans- Both non-static const data members and reference data members cannot be assigned values; instead, you should use initialization list to initialize them.
Can you overload a function based only on whether a parameter is a value or a reference?
Ans- No. Passing by value and by reference looks identical to the caller.
What are the differences between a C++ struct and C++ class?
Ans- The default member and base class access specifiers are different.
The C++ struct has all the features of the class. The only differences are that a struct defaults to public member access and public base class inheritance, and a class defaults to the private access specifier and private base class inheritance.
What does extern "C" int func(int *, Foo) accomplish?
Ans- It will turn off "name mangling" for func so that one can link to code compiled by a C compiler.
How do you access the static member of a class?
Ans- <ClassName>::<StaticMemberName>
This comment has been removed by the author.
ReplyDelete