Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to hard code a Link list

33 views
Skip to first unread message

K' Dash

unread,
Nov 6, 2014, 4:14:44 PM11/6/14
to
Hello All

I want to hard code the link list., please see the figure
________________________
|GUID_address|IPaddress|
| | |
| | |
| | |
| | |
------------------------

I wrote this code in header (.h)file:
******************************************************************************
bool GetMatchingGUID (GUID_address guidaddress,Ipv4Address currentIP);

struct MappingTable
{
GUID_address GUIDaddr;
Ipv4Address IPaddr;
};
typedef std::list<struct MappingTable> MAPTble;
typedef std::list<struct MappingTable>::iterator MAPTbleI;
MAPTble m_mappingTable;
******************************************************************************
I want to hard code the GUID address column and the other one just remain an empty , on request I want to fill it. please tell me how to write the code in its .cc file?
one thing more I want to call this list in constructor as well.





Christopher Pisz

unread,
Nov 6, 2014, 4:41:13 PM11/6/14
to
Not really sure what you are looking for.
Maybe this?

class Something
{
std::map<GUID_address, shared_ptr<Ipv4Address> m_map;

public:
Something()
{
shared_ptr<Ipv4Address> uninitialized;
m_map[GUID_address("1")] = uninitialized;
m_map[GUID_address("2")] = uninitialized;
}


void Later()
{
m_map[GUID_address("2")] = shared_ptr<Ipv4Address>(new
Ipv4Address());
}
};





Mr Flibble

unread,
Nov 6, 2014, 4:43:13 PM11/6/14
to
One should prefer unique_ptr to shared_ptr; only use shared_ptr if you
want sharing semantics.

/Flibble

Christopher Pisz

unread,
Nov 6, 2014, 4:57:39 PM11/6/14
to
Hard to tell without more requirement details. I assume he wants a
lookup for others to get a hold of the Ipv4 Address, store it, and use
it, so I went with shared_ptr. I'm just going by the name if the thing.






Message has been deleted
0 new messages