In C++
Write a class, named "TwoOrLess" with a header file (two_or_less.hpp) and an implementation file (two_or_less.cpp).
This is a class that acts much like a set, except it can hold 0, 1, or 2 duplicates of an int. You need to support the insert, count, and size methods with the same parameters and return types as the set class (see test cases).Extracted text: #include "two or_less.hpp" %3D 1 3 TwoOrLess thing; ASSERT_EQ(thing.size(), 0); thing.insert(0); 4 6. ASSERT_EQ(thing.size(), 1); 7 YOUR CODE'S OUTPUT IIOM from /usr/include/gmock/gmock-actions.h:51, from /usr/include/gmock/gmock.h:59, 29 30 31 from cpp_unit_test:0: cpp_unit_test:3:11: error: 'thing' was not declared in this scope ASSERT_EQ(thing.size(), 0); 32 33 34 35 cpp unit test:3:11: note: suggested alternative: cpp unit test:4:1: error: 'thing' was not declared in this scope 'this' 36 37 thing.insert(0); 38 cpp_unit_test:4:1: note: suggested alternative: thing.insert(0); 39 'this' 40 41 42 this CMakeFiles/runTests.dir/tests.cpp.o' failed CMakeFiles/runTests.dir/build.make:62: recipe for target make[2]: *** [CMakeFiles/runTests.dir/tests.cpp.o] Error 1 43 44Extracted text: 1 #include "two_or_less.hpp" 3 TwoOrLess thing; ASSERT_EQ(thing.size(), 0); ASSERT_EQ(thing.count(0), 0); 4 thing.insert(0); ASSERT_EQ(thing.size(), 1); ASSERT_EQ(thing.count(0), 1); 7 8. 9. 10 11 thing.insert(1); ASSERT_EQ(thing.size(), 2); ASSERT_EQ(thing.count(1), 1); ASSERT_EQ(thing.count(0), 1); 12 13 14 15 16 thing.insert(0); YOUR CODE'S OUTPUT cpp unit test:3:11: error: ' thing' was not declared in this scope ASSERT_EQ(thing.size(), 0); 32 33 34 35 cpp_unit_test:3:11: note: suggested alternative: 'this' cpp unit test:4:11: error: ' thing' was not declared in this scope 36 37 ASSERT_EQ(thing.count( 0 ), 0); 38 cpp_unit_test:4:11: note: suggested alternative: 'this' cpp_unit_test:6:1: error: 'thing' was not declared in this scope thing.insert(0); 39 40 41 42 cpp_unit_test:6:1: note: suggested alternative: 'this' thing.insert(0); 43 44 45 46 this
Extracted text: #include "two or_less.hpp" %3D 1 3 TwoOrLess thing; ASSERT_EQ(thing.size(), 0); thing.insert(0); 4 6. ASSERT_EQ(thing.size(), 1); 7 YOUR CODE'S OUTPUT IIOM from /usr/include/gmock/gmock-actions.h:51, from /usr/include/gmock/gmock.h:59, 29 30 31 from cpp_unit_test:0: cpp_unit_test:3:11: error: 'thing' was not declared in this scope ASSERT_EQ(thing.size(), 0); 32 33 34 35 cpp unit test:3:11: note: suggested alternative: cpp unit test:4:1: error: 'thing' was not declared in this scope 'this' 36 37 thing.insert(0); 38 cpp_unit_test:4:1: note: suggested alternative: thing.insert(0); 39 'this' 40 41 42 this CMakeFiles/runTests.dir/tests.cpp.o' failed CMakeFiles/runTests.dir/build.make:62: recipe for target make[2]: *** [CMakeFiles/runTests.dir/tests.cpp.o] Error 1 43 44Extracted text: 1 #include "two_or_less.hpp" 3 TwoOrLess thing; ASSERT_EQ(thing.size(), 0); ASSERT_EQ(thing.count(0), 0); 4 thing.insert(0); ASSERT_EQ(thing.size(), 1); ASSERT_EQ(thing.count(0), 1); 7 8. 9. 10 11 thing.insert(1); ASSERT_EQ(thing.size(), 2); ASSERT_EQ(thing.count(1), 1); ASSERT_EQ(thing.count(0), 1); 12 13 14 15 16 thing.insert(0); YOUR CODE'S OUTPUT cpp unit test:3:11: error: ' thing' was not declared in this scope ASSERT_EQ(thing.size(), 0); 32 33 34 35 cpp_unit_test:3:11: note: suggested alternative: 'this' cpp unit test:4:11: error: ' thing' was not declared in this scope 36 37 ASSERT_EQ(thing.count( 0 ), 0); 38 cpp_unit_test:4:11: note: suggested alternative: 'this' cpp_unit_test:6:1: error: 'thing' was not declared in this scope thing.insert(0); 39 40 41 42 cpp_unit_test:6:1: note: suggested alternative: 'this' thing.insert(0); 43 44 45 46 this
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here