About Me

All about Real time requirements in Orale Stay Tune!!

Monday, March 17, 2008

Interview Questions

What does extern mean in a function declaration?

It tells the compiler that a variable or a function exists, even if the compiler hasn’t yet seen it in the file currently being compiled. This variable or function may be defined in another file or further down in the current file.

How do I initialize a pointer to a function?

This is the way to initialize a pointer to a function
void fun(int a)
{
}
void main()
{
void (*fp)(int);
fp=fun;
fp(1);
}

How do you link a C++ program to C functions?

By using the extern "C" linkage specification around the C function declarations.

Explain the scope resolution operator.

It permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope.

What are the differences between a C++ struct and C++ class?

The default member and base-class access specifiers are different.

How many ways are there to initialize an int with a constant?

Two.

There are two formats for initializers in C++ as shown in the example that follows. The first format uses the traditional C notation. The second format uses constructor notation.
int foo = 123;
int bar (123);

How does throwing and catching exceptions differ from using setjmp and longjmp?

The throw operation calls the destructors for automatic objects instantiated since entry to the try block.


What is a default constructor?


Default constructor WITH arguments class B { public: B (int m = 0) : n (m) {} int n; }; int main(int argc, char *argv[]) { B b; return 0; }

0 comments: