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
prohojiy [21]
3 years ago
12

C++ code pls write the code

Computers and Technology
1 answer:
Mariana [72]3 years ago
6 0

Answer:

Following are the code to this question:

#include<iostream>//defining header file

using namespace std;

class vec//defining class vec  

{

int x, y, z; //defining integer varaible x, y, z

public: // using public access specifier

vec() //defining default constructor

{

   x = 0; //assign value 0 in x variable  

   y = 0; //assign value 0 in y variable

   z = 0;//assign value 0 in z variable

}

vec(int a, int b , int c) //defining parameterized constructor vec

{

   x = a; //assign value a in x variable

   y = b; //assign value b in y variable

   z = c;//assign value c in z variable

}

void printVec() //defining a method printVec

{

   cout<<x<<","<<y<<","<<z<<endl; //use print method to print integer variable value

}

//code

vec& operator=(const vec& ob) //defining operator method that create object "ob" in parameter  

{

x=ob.x; //use ob to hold x variable value

y=ob.y;//use ob to hold y variable value

z=ob.z;//use ob to hold z variable value

return *this;//using this keyword to return value  

}

};

int main()//defining main method

{

vec v(1,2,3);//calling parameterized constructor

vec v2; //creating class object to call method

v2=v; //creatring reference of object

v2.printVec(); //call method printVec

return 0;

}

Output:

1, 2, 3

Explanation:

In the above-given code part, a method "operator" is defined, that accepts an object or we can say that it is a reference of the class "ob", which is a constant type. Inside the method, the object is used to store the integer variable value in its variable and use the return keyword with this point keyword to return its value.    

You might be interested in
Which of these is an effective color scheme?
irga5000 [103]

Answer:

Yellow on white.

Explanation:

Not to bright, soft, and easy to see.

4 0
3 years ago
What can always be seen in the styles gallery??
tankabanditka [31]
<span>The quick styles gallery is the place where the available sets of fonts, designs, settings designed and stored in office applications. </span><span>The styles are all presented as examples in the gallery. </span><span> </span><span> </span><span>If a computer user wanted one of these styles, he can click one style and then it would automatically be applied to the document.  A style can be used, created and be removed if wanted.</span>
6 0
3 years ago
A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To ac
denpristay [2]

Answer:

import java.util.Scanner;

public class LabProgram {

   public static void main(String[] args) {

       Scanner scnr = new Scanner(System.in);

       int inputYear;

       boolean isLeapYear;

       isLeapYear = false;

       inputYear = scnr.nextInt();

       // If a year is divisible by 400,  then it is a leap year

       if (inputYear % 400 == 0)

           isLeapYear = true;

       // If a year is divisible by 100,  then it is not a leap year

       if (inputYear % 100 == 0)

           isLeapYear = false;

       // If a year is divisible by 4,  then it is a leap year

       if (inputYear % 4 == 0)

           isLeapYear = true;

       if(isLeapYear)

           System.out.println(inputYear + " is a leap year.");

       else

           System.out.println(inputYear + " is not a leap year.");

   }

}

Explanation:

If a year is divisible by 400,  then set the boolean isLeapYear to true. If a year is divisible by 100,  then set the boolean isLeapYear to false. If a year is divisible by 4,  then set the boolean isLeapYear to true.

Check if isLeapYear is true, then print that it is a leap year. Otherwise, print that it is not a leap year.

Output:

1712

1712 is a leap year.

5 0
3 years ago
Read 2 more answers
Should students be able to use their phones during class
Allushta [10]
Hmm..This is a tough answer it all depends on how the students use their cell phones and if they can handle the privilege...And if they could "Sure why not" and you should monitor the students too
5 0
3 years ago
Which of the following options correctly represent a formula with Absolute References?
lakkis [162]
The answer is D =(<span>$A$1-$B$1) 

sources:just took the test</span>
3 0
3 years ago
Read 2 more answers
Other questions:
  • Jason is a computer hardware engineer. His work involves assembling computers. What will Jason need to assemble a microcomputer
    11·2 answers
  • One of the network printers is producing copies where the toner is smeared on paper after printing. What component should be che
    11·1 answer
  • A spreadsheet can be filtered only by one column at a time? <br> true or false
    14·2 answers
  • Importance of being having data on hand​
    7·1 answer
  • Differentiate between the broadcasting and telecommunication
    5·1 answer
  • To type a small letter "z", you would use the right little finger. (5 points)True False
    9·1 answer
  • What is the answer to in Microsoft Word you can access the blank from the command command from the mini toolbar what is the corr
    10·2 answers
  • Type the correct answer in the box. Spell all words correctly.
    12·2 answers
  • How do i automate survey monkey results to my email
    11·1 answer
  • How do I find unwanted programs on my computer?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!