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

what does exactly the linker do?

1 Answers  


What is the difference between const int *ptr and int const *ptr???

2 Answers  


What are the benefits of oop?

0 Answers  


Explain the concepts involved in Object Oriented programming.

0 Answers   Wipro,


What is the difference between pass by reference and pass by value?

12 Answers   Pfizer, TCS,


How to calculate the age from the date of birth by using the program?

2 Answers   Accenture,


I have One image (means a group photo ) how to split the faces only from the image?............ please send the answer nagadurgaraju@gmail.com thanks in advace...

0 Answers  


What is oops and its features?

0 Answers  


What are the main differences between procedure oriented languages and object oriented languages?

9 Answers   IBM, Infosys, Wipro,


Explain virtual inheritance?

0 Answers  


what is the advantage in software? what is the difference between the software developer and Engineer

1 Answers  


Name an advantage of linked list over array?

11 Answers   IBM, Infosys,


Categories