I could get the answers by trying things with a compiler, but I'm very very very busy, so I'm asking here. It saves time, of which I hardly have any for programming. ( please ignore the weird indentation...it's not intended...)
1. Inside a header file, there is
#define NONE 0
. The header file is included in a source file. Will the #define replace all the NONE in the source file?
2. Can macro definitions affect other macro definitions?
1 2
|
#define ABC 0
#define ABCD 2
|
Will the first #define convert the second one into
#define 0D 2
?
3.
1 2
|
#define A 0
#define AB 1
|
Does this guarantee that every A is replaced by 0 before any AB is replaced by 1 (supposing the answer to question no. 2 is no) ?
4. Does typedef work with classes?
1 2 3 4 5
|
class MyClass
{
/* . . . */
};
typedef MyClass* MyPtr;
|
5. How do I use a global variable outside the source file in which it is declared? (let's say file1.cpp contains
int a=0;
in the global scope. How do I use the variable
a
in file2.cpp ?
6. Can class A have a static member of type A?
7. Can new allocate arrays of pointers?
1 2
|
int** ptr = new int* [5];
MyClass** ptr2 = new MyClass* [5];
|
8. What is the common value (or what are the common values) of CLOCKS_PER_SEC
(which is defined in the ctime library) ?
9. Does converting a variable of type double containing a positive value smaller than 2^32 (^ is power here...) into unsigned int simply cut the decimal part?
10. Can static members be private? Can a private static data member be initialized in the global scope (according to the tutorial, static members are initialized in the global scope, but generally private members can't be accessed from the global scope, so I'm wondering...) ? If not, where is it initialized?
11. Do I have to specify the scope when using a function that is define inside a namespace? For example, if I use the function clock() without
using namespace std;
, do I have to type
std::clock();
when I use the function?
12. Inside member functions, members can be written without the this pointer (member instead of this->member ). Does it work with member functions too?
13. Is there a difference (in ASM and machine code) between these:
func(1);
If there's a difference, which func() is faster, func(a) of func (1) ?
Help will be highly appreciated...I really need the answers.
:)