There are 2 classes defined as below

public class A
{
class B b;
}
public class B
{
class A a;
}
compiler gives error. How to fix it?

Answers were Sorted based on User's Feedback



There are 2 classes defined as below public class A { class B b; } public class B { c..

Answer / santhosh

by Forward declaring,

class B;

public class A
{
class B b;
}
public class B
{
class A a;
}

Is This Answer Correct ?    11 Yes 1 No

There are 2 classes defined as below public class A { class B b; } public class B { c..

Answer / santhosh

class B;


public class A
{
B* b;
}
public class B
{
A a;
}

Is This Answer Correct ?    4 Yes 0 No

There are 2 classes defined as below public class A { class B b; } public class B { c..

Answer / praveen

public class A
{
class B *b;
}
public class B
{
class A a;
}

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More OOPS Interview Questions

IN PROGRAMING LANGAUGE A C++ IS PURELY OBJECT ORIENTED OR NOT?

2 Answers  


What is operator overloading? Give Example

11 Answers   CTS, IBM, TCS,


What are the 4 pillars of oop?

0 Answers  


what is inline function?

3 Answers  


what is multithreading in c++ , what is difference between multithreading and singlethreading.

4 Answers  


what are the realtime excercises in C++?

0 Answers   IBM, Wipro,


What are benefits of oop?

0 Answers  


write string class as your own class in java without using any built-in function

0 Answers  


what is an qt4 interface?

1 Answers   IBM,


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create.

1 Answers  


What is encapsulation selenium?

0 Answers  


if i have same function with same number of argument but defined in different files. Now i am adding these two files in a third file and calling this function . which will get called and wht decide the precedence?

1 Answers  


Categories