Search

Wednesday, September 25, 2013
0 comments

Instance of class cann’t access member of the class within the class

5:12 AMWednesday, September 25, 2013

“Clubing data member and member function known as class.”

lets take an Example
Class A
{
Data member;
Member function;
}

If we create instance of the class in other class, that instance cannot access member of the class

lets take an Example

Class B
{
A  obj=new A();
A.Datamember;  // Error  instance member cann’t access datamember within the class
}

Solution :
Every executable statementmust be in a definition block( inside a function , constructor)
Class B
{
A obj =new A();
Public B()
{
Obj.DataMember=value; // you can access the datamember

}
Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top