Hi all.....
i'm studying for a job interview and i have a few questions:
1.Should a refrence be initialized ?
i'm not sure if the answer is YES, or NOT ALWAYS.
2. given the following code:
int x = 9
void func()
{
int x;
x = 4;
}
void main()
{
func();
Printf("%d",x);
}
what will be the result? - in my opinion x is still 9 but i someone told it is 4.
so , what is the right answear?
3.does TEMPLATES represent the dynamic or static side
i think static, but again not sure....
well, that is al for now!
ty all
amir
1. A reference must always be initialized. It's not possible to have an uninitialized reference.
2. It will print 9, because the other x is a local variable. Also notice that void main() is not allowed by the standard. The return type must be int.
3. Templates are compiled to whatever types are being used. So they enable static polymorphism.
thanks for the quick reply.
can u maybe explain what do u mean by "static polymorphism" ?
Polymorphism where the types are known at compile time