Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pointers (help)

Status
Not open for further replies.

hectorDUQUE

Programmer
Jan 29, 2007
23
hi guys,
please some help with pointers:

this STLplus code is good:

Code:
int main(int argc, char* argv[])
{
   digraph<string,int> graph;
   digraph<string,int>::iterator node1 = graph.insert("1");
}

this one has a reference problem:

Code:
void initGraph(const digraph<string,int>& graph){
    digraph<string,int>::iterator node1 = graph.insert("1");
}
int main(int argc, char* argv[])
{
   digraph<string,int> graph;
   initGraph(graph);
}

error: passing ‘const digraph<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int>’ as ‘this’ argument of ‘typename digraph<NT, AT>::iterator digraph<NT, AT>::insert(const NT&) [with NT = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, AT = int]’ discards qualifiers


the type of insert is:
iterator insert(const NT& node_data);


i am sure this is a easy one for you guys ...
thanks in advance.

hector


 
Probably because you're trying to modify something which you declared as const (hence the "discards qualifiers").


--
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
 
yeah; just don't declare as a const type.
thanks,

hector
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top