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 is the purpose of polymorphism?

0 Answers  


Given two strings like x=?hello? and y=?open?, remove any character from string x which is also used in string y, thus making the result x=?hll?.

13 Answers   IBM,


write a c++ code of diagonal matrix.

2 Answers  


What is data binding in oops?

0 Answers  


What is the correct syntax for inheritance? 1) class aclass : public superclass 2) class aclass inherit superclass 3) class aclass <-superclass

6 Answers   Wipro,






What is a function in oop?

0 Answers  


Difference between over loading and over ridding?

12 Answers   CTS, Patni, Softvision Solution,


There are two base class B1,B2 and there is one class D which is derived from both classes, Explain the flow of calling constructors and destructors when an object of derived class is instantiated.

0 Answers  


Get me an image implementation program.

0 Answers  


How long to learn object oriented programming?

0 Answers  


which structured data type is not used in c++? 1.union 2.structure 3.string 4.boolean

2 Answers   HCL, Wipro,


What does enum stand for?

0 Answers  


Categories