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

What is abstract class in oop?

733


What is byval and byref? What are differences between them?

1926


What is the full form of oops?

900


assume the program must insert 4 elements from the key board and then do the following programs.sequential search(search one of the elements),using insertion sort(sort the element) and using selection sort(sort the element).

1878


Give two or more real cenario of virtual function and vertual object

2057


What is polymorphism what is it for and how is it used?

752


write a program to enter a string like"sunil is a good boy and seeking for a job" not more than 10 characters including space in one line,rest characters should b in other line.if the next line starts from in between the previous word,then print whole word to next line.

1975


What are two types of polymorphism?

799


What is encapsulation c#?

799


What is static in oop?

817


What are the 5 oop principles?

822


write a code for this:trailer recordId contains a value other than 99, then the file must error with the reason ‘Invalid RECORD_ID’(User Defined Exception).

1884


What is polymorphism in oops with example?

750


What are the three main types of variables?

815


What are benefits of oop?

857