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 polymorphism explain its types?

0 Answers  


Define a class to represent a bank account. Include the following members: Data Members: Name of the Depositor Account Number Type of Account Balance amount in the account Member Functions: To assign the initial values. To deposit an account. To withdraw an amount after checking the balance. Write a C++ main program to display account number, name and balance.

6 Answers  


what are the ways in which a constructors can be called?

2 Answers   TCS,


how to find the correct email address format by using the programe?

1 Answers   Accenture,


What are oops methods?

0 Answers  


Can we override main method?

0 Answers  


sir plz send me a set of questions that been frequently held in written examination during campus selection.

0 Answers   TCS,


What is virtual function?where and when is it used?

2 Answers   Sitel,


can you give the dynamic polymorphism types?

2 Answers   Wipro,


which feature are not hold visual basic of oop?

0 Answers   Ignou,


What is abstraction with example?

0 Answers  


What are callback functions in c++

1 Answers   SoftTech,


Categories