Question
c++
2) Carefully examine the function definition for Addem and the two lines of code that used Addem(); can the following code be
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The following code can not be compiled.

The given code is using the concept of call by reference. The variable reference is passed in call by reference and the changes made to the variable to which the value is passed is reflected back to the previous. But in this scenario a constant value of 4 is passed to the function Addem(). So, instead of the variable reference the value itself is passed and this will provide error.

Hope this helps.

Add a comment
Know the answer?
Add Answer to:
c++ 2) Carefully examine the function definition for Addem and the two lines of code that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Add and subtract polynomials using linked lists: The output should look like the following: The code...

    Add and subtract polynomials using linked lists: The output should look like the following: The code for the header file, Polynomial.h, is given as such: ***********HEADER************* #include <iostream> #include <cstdlib> using namespace std; class polyll { //this is class POLYLL, but all lower case private: struct polynode { float coeff; int exp; polynode* link; } * p; public: polyll(); void poly_append(float c, int e); void display_poly(); void poly_add(polyll& l1, polyll& l2); void poly_subtract(polyll& l1, polyll& l2); ~polyll(); }; polyll::polyll() {...

  • Study the c++ code below and answer the question on templates after // A polymorphic swap...

    Study the c++ code below and answer the question on templates after // A polymorphic swap function for any type of object (an example) template<typename T> void MySwap( T& x, T& y) { T temp; temp = x; x = y; y = temp; } // A polymorphic class holding an [x,y] position of any type template<class T> class Position { public: Position(T x=0, T y=0) : x_(x), y_(y) {} friend std::ostream& operator<<(std::ostream& os, const Position& p) { return os...

  • 1. What is output by the following code: ArrayList< Integer > a = new ArrayList< Integer...

    1. What is output by the following code: ArrayList< Integer > a = new ArrayList< Integer >(); ArrayList b = a; a.add(new Integer(4)); b.add(new Integer(5)); a.add(new Integer(6)); a.add(new Integer(7)); System.out.println(b.size()); A)1 B)2 C)3 D)4 E)5 2. Assume the Student and Employee classes each extend the Person class. The Student class overrides the getMoney method in the Person class. Consider the following code:     Person p1, p2, p3;     int m1, m2, m3;     p1 = new Person();     m1 = p1.getMoney();     // assignment 1...

  • USING C++: Referring to the header file below named coord2d.h, Implement each of the 8 operator...

    USING C++: Referring to the header file below named coord2d.h, Implement each of the 8 operator overloads (operators: <<, [], >, <, two versions of +, two versions of *) #ifndef COORD2D_H #define COORD2D_H #include <iostream> using namespace std; //implement a class that keeps track of the coordinates of a point in the X-Y plane class coord2d { //overload the << operator so that if p is of type "coord2d" then "cout<<p"; //will print out (x_coord, y_coord) //e.g. if p.x_coord=3.4,...

  • Write the c++ code that will run with visual studio With the square function below as...

    Write the c++ code that will run with visual studio With the square function below as an example, write a max function that has two int parameters and will return back the larger of the two. Also write a main which can be used to test your function. ex ) int square(intnum); // funcprototype int main() {    inta = 5, b; a = square(a);    b = square(4);cout<< square( 6 ) << endl;    ....        // func...

  • 1. A(n) ____________________ is a variable or expression listed in a call to a function. 2....

    1. A(n) ____________________ is a variable or expression listed in a call to a function. 2. The pass by ____________________ mechanism must be used if the calling code is to receive information back from the function. 3. True or False? If there are several items in a parameter list, the compiler matches the parameters and arguments by their relative positions in the parameter and argument lists. 4. True or False? In C++, a function definition may have another function definition...

  • MSP430 Misc.peripherals. Consider the following C source code. What does the code segment from lines 9...

    MSP430 Misc.peripherals. Consider the following C source code. What does the code segment from lines 9 ~ 12 do? USCIA0 is configured in the UART mode. Consider the following C source code. 1. char gm1[]"MSP430"; 2. void UARTO_putdchar (char c) l 3. while (! (IFG2 & UCAOTXIFG)) UCAOTXBUF 5. while (! (IFG2 & UCAOTXIFG)) 6. UCAOTXBUF=''; 7 - 9. for (int i=0; i < 6; ¡++) { 10. ch gml [il; 11 UARTO putdchar (ch) 12. ) D. (4 points)...

  • Modify the program q1.c by adding calls to uthread_join (and making no other changes) so that...

    Modify the program q1.c by adding calls to uthread_join (and making no other changes) so that it always prints the lines “zero” to “three” in order; i.e., its output must always be the following. q1.c code as below: #include <stdlib.h> #include <stdio.h> #include "uthread.h" uthread_t t0, t1, t2; void randomStall() { int i, r = random() >> 16; while (i++<r); } void* p0(void* v) { randomStall(); printf("zero\n"); return NULL; } void* p1(void* v) { randomStall(); printf("one\n"); return NULL; } void*...

  • Q3. In a (7,4) Hamming Code, three parity bits p1, p2, p3 are added to four...

    Q3. In a (7,4) Hamming Code, three parity bits p1, p2, p3 are added to four data bits dl, d2, d3, and d4, and the coverage of each parity bit is as shown in the table below: Bit position 2 3 4 5 6 7 Encoded data bits p1 p2 di p3 d2 d3 d4 da X p1 X X X x Parity bit coverage p2 х X X p3 X X X х 1) (3 pts) Assume even parity...

  • Programming in C: The following lines of code, when arranged in the proper sequence, output the...

    Programming in C: The following lines of code, when arranged in the proper sequence, output the simple message “All your base are belong to us.” 1. return 0; 2. const char msg[] = MSG1; 3. } 4. #define MSG1 "All your base are belong to us!" 5. int main(void) { 6. #include 7. puts(msg); Write out the proper arrangement (line numbers are sufficient) of this code.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT