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?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we override main method?

603


What is the renewal class?

2161


What is class and example?

567


What is polymorphism and why is it important?

556


What is the real life example of polymorphism?

605






why reinterpret cast is considered dangerous?

1898


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?

2753


Give an example where we have to specifically use C programming language and C++ programming language cannot be used?

1145


Whats is abstraction in oops?

589


Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.

2006


How to hide the base class functionality in Inheritance?

636


What is a class in oop?

599


what is the 3 types of system development life cycle

2431


Why is oop better than procedural?

602


What is balance factor?

582