Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

8: Why doesn't this code compile? b) How to change the definition of Token class members so that the code compiled, and at the same

8: Why doesn't this code compile? b) How to change the definition of Token class members so that the code compiled, and at the same time that the objects in std :: set s are stored according to the comparator used? (C++)

1 #include 2 #include 34 class Token { 5 public: 6 int a(); 7 Token(int i0) : a(i0) {}; 8 bool operator<(const Token& t0) { return a < t0.a; } 9 }; 10 11 int main() { 12 bool (*comp)(const Token&, const Token&) = [](const Token& t0, const Token& t1) > bool { 13 return t0 < t1; 14 }; 15 16 std::set s(comp); 17 18 for(int i=0; i<3; ++i) { s.emplace(i); } 19 20 for(auto i : s) { std::cout << i.a << std::endl; } 21 22 return 0; 23 }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions

Question

Complexity of linear search is O ( n ) . Your answer: True False

Answered: 1 week ago