Home > Software engineering >  Seek a simple method is called
Seek a simple method is called

Time:09-26

 # include "B.h 
"Class A
{
The public;
B B;
Void setXXX (init n);
}


Class B
{
//optional
}

How do I calls A method in A Class B void setXXX (init n);

CodePudding user response:

 A: : setXXX (0);//? 

CodePudding user response:

reference 1st floor zhao4zhong1 response:
 A: : setXXX (0);//? 


Don't know A B, no

CodePudding user response:

Object-oriented is a kind of programming ideas,
To abstract programming language, is not the last into the assembly code? It is fair to say the assembler language is object oriented, scripting, dynamic, functional, parallel and distributed language,

"Depth explore c + + object model"
"C + + the disassembly and reverse analysis reveal"

CodePudding user response:



Class B calls A method, or make A setXXX into static function, so direct A: : setXXX calls everywhere,

Inherit A or B, the method of automatically receive A attribute, try not to know

CodePudding user response:

Public:
B (A * pObj) {}
~ (B)

A object pointer passed to go,

CodePudding user response:

Initialization of B object when initialized in A constructor,
 B to B B * m_pObjB statement A: : A () {m_pObjB=new B (this); } 

CodePudding user response:

refer to 6th floor pcradio response:
object initialization of B when initialized in A constructor,
 B to B B * m_pObjB statement A: : A () {m_pObjB=new B (this); } 


In fact,
Class B is a Dlg
I was also B * B pointer declarations,
Just not in the constructor of A new,

You are emphasized in the initialization function of A new, is there any difference between with new elsewhere?

CodePudding user response:

refer to 7th floor sharp0077 response:
Quote: refer to the sixth floor pcradio response:

Initialization of B object when initialized in A constructor,
 B to B B * m_pObjB statement A: : A () {m_pObjB=new B (this); } 


In fact,
Class B is a Dlg
I was also B * B pointer declarations,
Just not in the constructor of A new,

You are emphasized in the initialization function of A new, is there any difference between with new elsewhere?

No difference, basically see you whether the initialization time will affect your code logic,

CodePudding user response:

Initialization of A, B, only in A contain A is B, if A and B are separated

CodePudding user response:

B class defined in the class A pointer variable ~
  • Related