© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu

C and C++ Interview Questions

12. How Virtual functions call up is maintained?
Ans:

Through Look up tables added by the compile to every class image. This also leads to performance penalty.

Ex - 1: What is the output?

main()
            {
            main();
            }

Ans:
 Runtime error : Stack overflow.

Explanation:

main function calls itself again and again. Each time the function is called its return address is stored in the call stack. Since there is no condition to terminate the function call, the call stack overflows at runtime. So it terminates the program and results in an error.

Ex - 2: What are the number of syntax errors ?
int f()
void main()
{
f(1);
f(1,2);
f(1,2,3);
}
f(int i,int j,int k)
{
printf("%d %d %d",i,j,k);
}

Ans: None.


SLogix Student Projects
bottom