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]
4 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]4 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
A sequence of data values separated by commas can be made into a list by enclosing the sequence in what type of symbols?
Dovator [93]

Answer:

square brackets [ ]

Explanation:

In python programming language a list is a data structure type that contains data values which can be of different data types separated by commas and enclosed in a pair of square brackets. in the example below, I have created a list and initialized the values

MyList = [ 2,3,4,5,"David", 2.5, 5.8].

This list contains three different data types integers, float and a string

This code below will produce the output that is attached as an image

<em>MyList = [2,3,4,5,"David"]</em>

<em>print(MyList[0])</em>

<em>print(MyList[1])</em>

<em>print(MyList[2])</em>

<em>print(MyList[3])</em>

<em>print(MyList[4])</em>

<em>Observe that list follow the zero-based indexing</em>

3 0
3 years ago
I'll give u 16 points answer thisss
irga5000 [103]
Big hero six was the greatest kid movie ever invented like there is no question about that I love that movie
5 0
2 years ago
Does any body like animal jam
cricket20 [7]

Answer:

Never used it so I do not know.

Explanation:

To be honest i thought you meant like animal jelly at first

7 0
4 years ago
Read 2 more answers
What Fortnite skin is more og?
gregori [183]
It’s elite agent i think ??
red nose raider comes out on christmas
7 0
3 years ago
Read 2 more answers
What are the services offered by web-based email?​
slega [8]

Answer:

Web based email is a service that allows to access and use electronic mail via web browser.

It allows clients to login into the email software running on a web server to compose, send and receive, delete mails basically.

8 0
3 years ago
Other questions:
  • What is <br> Warehouse schema.
    14·1 answer
  • What is an individual piece of data called in a database? coding A field B file C record or D tittle
    9·1 answer
  • Write an if/else statement that compares the variable age with 65, adds 1 to the variable seniorCitizens if age is greater than
    14·1 answer
  • Which type of natural hazard is sometimes caused by human activity?
    6·1 answer
  • How do you feel about your self as a responsive citizen?​
    7·1 answer
  • Memory is the place of the computer where data and instructions are stored either permanently or temporarily. True or false.​
    11·1 answer
  • A(n) _____ describes your core values and highest career goals. A. résumé B. objective statement C. qualifications profile D. pe
    7·2 answers
  • A user complains that her computer is performing slowly. She tells you the problem started about a week ago when new database so
    12·1 answer
  • What will happen if you reverse the connection of IDE?<br>​
    9·1 answer
  • State whether the following statement are true or false​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!