1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
alukav5142 [94]
3 years ago
14

c++ design a class named myinteger which models integers. interesting properties of the value can be determined. include these m

embers: a int data field named value that represents the integer's value. a constructor that creates a myinteger object with a specified int value. a constant getter that returns the value
Computers and Technology
1 answer:
klemol [59]3 years ago
4 0

Answer:

  1. #include <iostream>
  2. using namespace std;
  3. class myinteger {
  4.    
  5.    private:
  6.        int value;
  7.        
  8.    public:
  9.        myinteger(int x){
  10.            value = x;
  11.        }
  12.        
  13.       int getValue(){
  14.           return value;
  15.       }
  16.        
  17. };
  18. int main()
  19. {
  20.    myinteger obj(4);
  21.    cout<< obj.getValue();
  22.    return 0;
  23. }

Explanation:

Firstly, we use class keyword to create a class named myinteger (Line 5). Define a private scope data field named value in integer type (Line 7 - 8).

Next, we proceed to define a constructor (Line 11 - 13) and a getter method for value (Line 15 -17) in public scope. The constructor will accept one input x and set it to data field, x. The getter method will return the data field x whenever it is called.

We test our class by creating an object from the class (Line 23) by passing a number of 4 as argument. And when we use the object to call the getValue method, 4 will be printed as output.

You might be interested in
Write code that read from variables N and M, multiply these two unsigned 32-bit variables and store the result in Variables P, Q
Tamiku [17]

Answer:

Using C language;

#include <stdio.h>

int main()

{

int N, M;

printf("Please enter two numbers: ");

scanf("%d %d", &N, &M);

int P,Q = N*M;

return 0;

}

Explanation:

The variables N and M are declared and the "scanf" function is used to assign a value to the variables from the input prompt, then the product of N and M are saved to the P and Q variables.

8 0
3 years ago
Which of these is one of the primary concerns for protecting your family when online?
Lady_Fox [76]
Sharing personal information
7 0
3 years ago
Read 2 more answers
How do you innovate or improve a product?
In-s [12.5K]

Answer:in order to innovate or improve a product you need to have an idea

Explanation:

5 0
3 years ago
Select Packet 10 in the Wireshark top pane and then answer the following questions: Did this handshake complete properly? What i
Yuki888 [10]

Answer:

Yes

32 bytes

No

40 bytes

6 0
3 years ago
There are ____ standard colors for text in a theme.
soldier1979 [14.2K]
In microsoft powerpoint there are 2 or two standard colors for text in a theme. If you use a theme on your presentation, a theme is always equipped with two types of colors for the text, because it gives you more options on what color suits your text and blends with the theme perfectly.
7 0
3 years ago
Other questions:
  • What is the recommended size for bulleted text? 12–22 24–40 44–66 54–80
    10·1 answer
  • The first character of the VIN designates which of the following? 
    15·2 answers
  • Are commonly used to control the number of times that a loop iterates?
    5·1 answer
  • Which of the following statements about the FAFSA process are TRUE?
    6·1 answer
  • There are several methods of updating information and data on a webserver. We must consider who performs those updates upfront w
    9·2 answers
  • ____ devices are high-performance storage systems that are connected individually to a network to provide storage for the comput
    5·1 answer
  • Which two options are negotiated via ncp during the establishment of a ppp connection that will use the ipv4 network layer proto
    7·1 answer
  • A computer (mainframe, server, or workstation) that has an operating system enabling _____________ to access it at the same time
    11·1 answer
  • Which option should you select to ignore all tracked changes in a document? To ignore all tracked changes in a document, you sho
    14·1 answer
  • True or False <br> Hebrew Bible and the Koran were first written in English.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!