231 views
0 votes
0 votes
A B
class Foo
{
 int i;
 public:
int g()
{return i;}
 int f() 
{return g()+10;}  
 
};
class Foo
{
 int i;
 public:
 int f() 
{return g()+10;} 
 int g()
 {return i;}
};

Select the correct statement.

I.  A and B will be compiled succesfully.

II. A will be compiled but B will cause compilation error as f() calls g() before it is declared.

III. A will cause compilation error as f() calls g() after it is declared.

IV. Both A and B will cause compile error as member functions f() and g() cannot call each other

1 Answer

1 votes
1 votes
Both functions will compile successfully because ordering of functions within class declaration doesn't matter and functions can call other functions even declared after them.

Related questions

0 votes
0 votes
1 answer
1
shree asked Nov 22, 2014
501 views
What will be the second value printed by the program if parameter passing mechanism is call by reference?int b=10 //global begin procedure func(int x,int y) begin print(b...
0 votes
0 votes
0 answers
2
sushmita asked Jan 18, 2017
864 views
foo(a, b, c) { b =b++; a = a++; c = a + b*10 } X=1; Y=2; Z=3; foo(X, Y+2, Z);CAN SOMEONE PLEASE TELL THE OUTPUTS FOR CALL BY REFERENCE AND CALL BY NAME. WHAT IS THE DIFER...
2 votes
2 votes
1 answer
3
Akriti sood asked Dec 8, 2016
12,050 views
Which of the following symbol table implementation is based on the property of locality of reference? Self-organizing list Hash tree Search tree Array