Write a class, named "TwoOrLess" with a header file (two_or_less.hpp) and an implementation file (two_or_less.cpp).
Write a class, named "TwoOrLess" with a header file (two_or_less.hpp) and an implementation file (two_or_less.cpp).
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
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<int> class (see test cases).
![#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
44](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F3d01a12a-1ab5-4b5b-8ac9-ffcff6df37dc%2Fa96e94b6-25b2-42c0-9bfe-535e060f7907%2Fag5n4do_processed.png&w=3840&q=75)
Transcribed Image 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
44
![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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F3d01a12a-1ab5-4b5b-8ac9-ffcff6df37dc%2Fa96e94b6-25b2-42c0-9bfe-535e060f7907%2F6d0xpvj_processed.png&w=3840&q=75)
Transcribed Image 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
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education