Set - 5

Question 6 :

How do I initialize a pointer to a function?

Answer :

This is the way to initialize a pointer to a function

void fun(int a){
}

void main(){
	void (*fp)(int);
	fp=fun;
	fp(1);
}

 


Question 7 :

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

Answer :

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


Question 8 :

Explain the scope resolution operator?

Answer :

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.


Question 9 :

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

Answer :

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


Question 10 :

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

Answer :

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