Re: Help for multiple class involved definition
On Dec 23, 12:49 am, fl <rxjw...@gmail.com> wrote:
On 22 d=E9c, 19:26, fl <rxjw...@gmail.com> wrote:
I am new to C++. I do not understand why the following definition of
"request_in_port" is a pointer:
.............................
typedef tlm::tlm_generic_payload *gp_ptr; // gene=
ric payload
. . . . .
sc_core::sc_port<sc_core::sc_fifo_in_if <gp_ptr> >
request_in_port;
............................
because I find that "request_in_port->read()" is used in this way:
............................
tlm::tlm_generic_payload *transaction_ptr; // transaction po=
inter
. . . . . .
transaction_ptr = request_in_port->read(); // get request =
from
input fifo
............................
I know that "gp_ptr" is a pointer,
<snip>
I am puzzled on why "request_in_port" is a pointer. Could you help me?
<snip>
I just find that there is a redefinenition of -> for:
"
sc_core::sc_port
"
See below please. So, the '->" in my original post does not mean
"request_in_port" is a pointer?
not necessarily, though it ought to have "pointer like" semantics
(that is is it should act like a pointer)
"->" has been redefined as a method indicator? Is it so used? Am I
right now? Thanks.
well, the -> operator has been redefined for this class. It's better
to think of all classes having a default operator->() (IMO)
//
-------------------------------------------------------------------------=
--=AD-
// CLASS : sc_port_b
//
// Abstract base class for class sc_port.
//
-------------------------------------------------------------------------=
--=AD-
// allow to call methods provided by the first interface
template <class IF>
inline
IF*
sc_port_b<IF>::operator -> ()
{
if( m_interface == 0 ) {
report_error( SC_ID_GET_IF_, "port is not bound" );
}
return m_interface;}
this is probably what C++ calls a "smart pointer". Your C++ reference
should be able to answer basic questions about templates and smart
pointers