jeudi 26 octobre 2017

Printing a pair out as a string

I am trying to print out a string from a const pair i declared

using Collatz = pair<long, vector<long> >;

However, in this function, it allows me to print the first value with no problems. When i want to print the second value, it makes me add the & symbol to it which then prints out the address. How do i get around this so I can print out the actual value.

string Collatz_to_string(const Collatz &p) {
ostringstream oss;
oss << p.first << "," << p.second;
return oss.str();
}

Candidate function not viable: no known conversion from 'const std::__1::vector >' to 'const void *' for 1st argument; take the address of the argument with &

Aucun commentaire:

Enregistrer un commentaire