Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 7. [20 pts] Given the following class definition: class Node private: ch

ID: 3824245 • Letter: P

Question

Problem 7. [20 pts] Given the following class definition: class Node private: char element Node next, public: Node (char e) element e, next NULL,), Node (char e, Node* N)telement e,next-N; void set element (char e) telementEe;) char read element() {return element) void set next(Node* N) {next N;) char& ref element() {return element, Node & ref next() {return next describe/draw the entities and memory usage utilized by the arguments and the return value of the member functions (variables, pointers, references, For example, a function defined as an additional inline member of the class Node: node read next() return next Return Value of type Node pointer Argument none

Explanation / Answer

class Node
{
    private:
        char element;
        Node* next;
    public:
        Node(char e) {element = e, next = NULL;}
        Node(char e, Node* N) {element = 3; next = N;}
       
        void set_element(char e) {element = e;}
        char read_element() {return element; }
        void set_next(Node* N) {next = N; }
       
        char& ref_element() {return element; }
        Node*& ref_next() {return next;}  
};
int f(int* p, int&a) {return (2+p*); }  
   Returns and integer variable.
   Arguments: and integer pointer p, and an integer a, passed by address.

Node(char e, Node* N) {element = e; next = N; }
   Returns nothing. A constructor will not have a return type.
   Arguments: a character variable e, and a Node pointer N.

void set_element(char e) {element = e; }
   This is a setter function, and will not have a return type, and will take an argument to set some of the member variable.
   Returns nothing.
   Arguments: a character variable e.

char read_element() {return element; }
   This is a kind of getter function, and will return some member variable, and will not take any input.
   Returns a character variable.
   Arguments: None.

void set_next(Node* N) {next = N; }
   Again a setter.
   Returns nothing.
   Arguments: a node pointer N.
char& ref_element() {return element; }
   Returns a character by address.
   Arguments: None.