本文整理汇总了C++中Host::setParent方法的典型用法代码示例。如果您正苦于以下问题:C++ Host::setParent方法的具体用法?C++ Host::setParent怎么用?C++ Host::setParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Host
的用法示例。
在下文中一共展示了Host::setParent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: disconnect
/* BEGIN FUNCTION DEFINITION */
void Router::disconnect( Host& h) {
// check that they are connected
if ( is_connected_host( &h ) )
{
h.setParent( NULL );
delete_host_entry( h.getAddress() );
remove_from_connected_hosts( &h );
}
else
cout << "Host " << h.getAddress() << " is not directly connected to Router " << address << " so this disconnection is forbidden!\n" << endl;
}
示例2: connectTo
/* BEGIN FUNCTION DEFINITION */
void Router::connectTo( Host& h ) {
if ( h.getParent() == NULL ) //check for unconnected host
{
h.setParent(this);
connected_hosts.push_back(&h);
add_host_to_rTable( h.getAddress() );
}
else
cout << "Unable to connect Host " << h.getAddress()
<< " to Router " << address << ". Host "
<< h.getAddress() << " is "
<< ((h.getParent()->getAddress()==address)?"already ":"")
<< "connected to Router " << h.getParent()->getAddress()
<< ".\n" << endl;
}