Category : set

I define a class named Quote and there is a multiset in it: class Quote { public: Quote()=default; Quote(const std::string& book, double sales_price) : bookNo(book), price(sales_price) {} std::string isbn() const { return bookNo; } private: std::string bookNo; static bool compare(const std::shared_ptr<Quote> &lhs, const std::shared_ptr<Quote> &rhs) { return lhs->isbn() < rhs->isbn(); } std::multiset<std::shared_ptr<Quote>, decltype(compare)*> items(compare); protected: ..

Read more

This is my first time using c++ and I am having trouble manipulating a set. The function is supposed to iterate through the set, find the pair of Regions* that have the least distance between them, insert a new Region* and remove the two selected Regions* from the list. However, when I call s.insert() the ..

Read more

set<string> getSubstring(string input, string output){ set<string> m; if(input.length() == 0){ m.insert(output); return m; } getSubstring(input.substr(1), output); getSubstring(input.substr(1), output + input[0]); } int main() { string input; cin>>input; set<string> a = getSubstring(input, ""); } I wanted to assign the set returned by above function to another set. What is the right way to do this. Below ..

Read more