1. Type in program 2.32, studentPtr.cpp and run the program. Identify how pointer of object is...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Type in program 2.32, studentPtr.cpp and run the program. Identify how pointer of object is implemented in the program. Change main () program to the second example. The second main () program create object using new operator and destroy the object using delete. Identify the difference of the methods used in the first main () and the second main(). // Program 2.32 // studentPtr.cpp - pointer to object #include <iostream> #include <string> using namespace std; class Student ( private: string studentName; unsigned long netrico; public: Student (string na, unsigned long no) (metricko no; studentNamena: } void print () I cout << "\nStudent's Name: " << studentName: cout << "\nStudent's Metric Number:" << metrico; } 12 void main() f student studenti ("Ahmad", 123123); // objek Student student student2 ("Abdullah", 234234): cout << "\nAddress of the object " cout << "\nAddress of studenti: " <<&studentl << "\nAddress of student2 << 6student2: student ptr: cout << "\n\nValue of the pointer "; ptr = student1; // pointer to studentl 2. cout << "\nValue of pointer student1: ptr=&student2; // pointer to student2 cout << "\nValue of pointer student2: ptr ->print(); " << ptr; " << ptr; Second main() that implemented operator new and delete. void main() { student *ptr = new student ("Ahmad", 123123); ptr>print(); delete (ptr); ptr = new student ("Abdullah", 234234); ptr ->print(); delete (ptr); 1. Type in program 2.32, studentPtr.cpp and run the program. Identify how pointer of object is implemented in the program. Change main () program to the second example. The second main () program create object using new operator and destroy the object using delete. Identify the difference of the methods used in the first main () and the second main(). // Program 2.32 // studentPtr.cpp - pointer to object #include <iostream> #include <string> using namespace std; class Student ( private: string studentName; unsigned long netrico; public: Student (string na, unsigned long no) (metricko no; studentNamena: } void print () I cout << "\nStudent's Name: " << studentName: cout << "\nStudent's Metric Number:" << metrico; } 12 void main() f student studenti ("Ahmad", 123123); // objek Student student student2 ("Abdullah", 234234): cout << "\nAddress of the object " cout << "\nAddress of studenti: " <<&studentl << "\nAddress of student2 << 6student2: student ptr: cout << "\n\nValue of the pointer "; ptr = student1; // pointer to studentl 2. cout << "\nValue of pointer student1: ptr=&student2; // pointer to student2 cout << "\nValue of pointer student2: ptr ->print(); " << ptr; " << ptr; Second main() that implemented operator new and delete. void main() { student *ptr = new student ("Ahmad", 123123); ptr>print(); delete (ptr); ptr = new student ("Abdullah", 234234); ptr ->print(); delete (ptr); 1. Type in program 2.32, studentPtr.cpp and run the program. Identify how pointer of object is implemented in the program. Change main () program to the second example. The second main () program create object using new operator and destroy the object using delete. Identify the difference of the methods used in the first main () and the second main(). // Program 2.32 // studentPtr.cpp - pointer to object #include <iostream> #include <string> using namespace std; class Student ( private: string studentName; unsigned long netrico; public: Student (string na, unsigned long no) (metricko no; studentNamena: } void print () I cout << "\nStudent's Name: " << studentName: cout << "\nStudent's Metric Number:" << metrico; } 12 void main() f student studenti ("Ahmad", 123123); // objek Student student student2 ("Abdullah", 234234): cout << "\nAddress of the object " cout << "\nAddress of studenti: " <<&studentl << "\nAddress of student2 << 6student2: student ptr: cout << "\n\nValue of the pointer "; ptr = student1; // pointer to studentl 2. cout << "\nValue of pointer student1: ptr=&student2; // pointer to student2 cout << "\nValue of pointer student2: ptr ->print(); " << ptr; " << ptr; Second main() that implemented operator new and delete. void main() { student *ptr = new student ("Ahmad", 123123); ptr>print(); delete (ptr); ptr = new student ("Abdullah", 234234); ptr ->print(); delete (ptr); 1. Type in program 2.32, studentPtr.cpp and run the program. Identify how pointer of object is implemented in the program. Change main () program to the second example. The second main () program create object using new operator and destroy the object using delete. Identify the difference of the methods used in the first main () and the second main(). // Program 2.32 // studentPtr.cpp - pointer to object #include <iostream> #include <string> using namespace std; class Student ( private: string studentName; unsigned long netrico; public: Student (string na, unsigned long no) (metricko no; studentNamena: } void print () I cout << "\nStudent's Name: " << studentName: cout << "\nStudent's Metric Number:" << metrico; } 12 void main() f student studenti ("Ahmad", 123123); // objek Student student student2 ("Abdullah", 234234): cout << "\nAddress of the object " cout << "\nAddress of studenti: " <<&studentl << "\nAddress of student2 << 6student2: student ptr: cout << "\n\nValue of the pointer "; ptr = student1; // pointer to studentl 2. cout << "\nValue of pointer student1: ptr=&student2; // pointer to student2 cout << "\nValue of pointer student2: ptr ->print(); " << ptr; " << ptr; Second main() that implemented operator new and delete. void main() { student *ptr = new student ("Ahmad", 123123); ptr>print(); delete (ptr); ptr = new student ("Abdullah", 234234); ptr ->print(); delete (ptr); 1. Type in program 2.32, studentPtr.cpp and run the program. Identify how pointer of object is implemented in the program. Change main () program to the second example. The second main () program create object using new operator and destroy the object using delete. Identify the difference of the methods used in the first main () and the second main(). // Program 2.32 // studentPtr.cpp - pointer to object #include <iostream> #include <string> using namespace std; class Student ( private: string studentName; unsigned long netrico; public: Student (string na, unsigned long no) (metricko no; studentNamena: } void print () I cout << "\nStudent's Name: " << studentName: cout << "\nStudent's Metric Number:" << metrico; } 12 void main() f student studenti ("Ahmad", 123123); // objek Student student student2 ("Abdullah", 234234): cout << "\nAddress of the object " cout << "\nAddress of studenti: " <<&studentl << "\nAddress of student2 << 6student2: student ptr: cout << "\n\nValue of the pointer "; ptr = student1; // pointer to studentl 2. cout << "\nValue of pointer student1: ptr=&student2; // pointer to student2 cout << "\nValue of pointer student2: ptr ->print(); " << ptr; " << ptr; Second main() that implemented operator new and delete. void main() { student *ptr = new student ("Ahmad", 123123); ptr>print(); delete (ptr); ptr = new student ("Abdullah", 234234); ptr ->print(); delete (ptr); 1. Type in program 2.32, studentPtr.cpp and run the program. Identify how pointer of object is implemented in the program. Change main () program to the second example. The second main () program create object using new operator and destroy the object using delete. Identify the difference of the methods used in the first main () and the second main(). // Program 2.32 // studentPtr.cpp - pointer to object #include <iostream> #include <string> using namespace std; class Student ( private: string studentName; unsigned long netrico; public: Student (string na, unsigned long no) (metricko no; studentNamena: } void print () I cout << "\nStudent's Name: " << studentName: cout << "\nStudent's Metric Number:" << metrico; } 12 void main() f student studenti ("Ahmad", 123123); // objek Student student student2 ("Abdullah", 234234): cout << "\nAddress of the object " cout << "\nAddress of studenti: " <<&studentl << "\nAddress of student2 << 6student2: student ptr: cout << "\n\nValue of the pointer "; ptr = student1; // pointer to studentl 2. cout << "\nValue of pointer student1: ptr=&student2; // pointer to student2 cout << "\nValue of pointer student2: ptr ->print(); " << ptr; " << ptr; Second main() that implemented operator new and delete. void main() { student *ptr = new student ("Ahmad", 123123); ptr>print(); delete (ptr); ptr = new student ("Abdullah", 234234); ptr ->print(); delete (ptr);
Expert Answer:
Answer rating: 100% (QA)
The program given in the question is in C programming language and asked that what is the difference ... View the full answer
Related Book For
Posted Date:
Students also viewed these algorithms questions
-
Thaarugo,inc, produces a GPS device that is becoming popular in parts of Scandinavia. When Thaarugo produces one of these, a printed circuit board (PCB) is used and it is populated with several...
-
I need python help. I do not not where to start and keep getting errors in my code. The dataset (CreditData.csv) classifies customers as "approved" or "not approved" (Yes or No) (i.e., target class)....
-
Problem 1: Workout Create an empty list called workout. 50 points Now using a loop take 5 numbers as inputs from keyboard. These inputted numb represent the number of hours you worked out per day in...
-
What constant should replace the question mark in this system so that the solution set is {(1, 1, 1)}? 2x - 3y + -5x + 2y z = 0 - 2 = x + y + 2z = ? 4 -4
-
Consider the chemical equilibrium involving H2O, H2, CO, and CO2, and no other substances. Show that the equilibrium constant at any temperature can be found using values from Table A.10 only.
-
A supply chain failure is defined as an interruption caused by external or internal operations that may have significant impact on an organisation's quality, delivery or cost impact to clients. In...
-
Identify and explain the purpose of each of the four perspectives included in the balanced scorecard. Give two examples of HR measures for each of the four areas that would demonstrate the value of...
-
University Food Systems, Inc., has issued a 40 percent stock dividend. The company has 752,000 shares authorized and 200,000 shares outstanding. The par value of the stock is $10 per share, and the...
-
Image transcription text Task.2b-is-the-capacitor-discharging-below. Current 1 Voltage 0 -1 171 172 173 174 -2 -5 . 50 51 52 53 54 (s) Simulation time (s) Simulation time 0.00 5.6 kS 100 UF HAL 10.0...
-
In 2023, Deon and NeNe are married filing jointly. Deon and NeNes taxable income is $1,390,000 (all ordinary), and they itemize their deductions as follows: real property taxes of $10,000, charitable...
-
2. [10 Pts.] The Colebrook equation given below is used to calculate the friction coefficient f for circular closed-conduit flows. The calculated coefficient is then used to calculate the pressure...
-
RFC Corp. has announced a $1.32 dividend. If RFCs price last price cum-dividend is $13.21, what should its first ex-dividend price be (assuming perfect capital markets)?
-
Do you agree that most employers probably want to obey the Americans with Disabilities Act but dont know exactly what they are required to do under the law? Do you think that most employers would...
-
ABC Corporation announced that it will pay a dividend to all shareholders of record as of Monday, April 2, 2012. It takes three business days of a purchase for the new owners of a share of stock to...
-
Candy making is a fun business, and so it is no surprise that it is fun to work at the Jelly Belly Candy Company of Fairfield, California. Although this company has cheesecake, buttered popcorn,...
-
Rajesh is considering two investments. The expected returns are 8% for investment A and 15% for investment B. The standard deviations are 6% and 10% for investments A and B, respectively. Which...
-
Q4 : Calculate the potential of hydrogen electrode in contact with a solution whose pH is 10.
-
Answer the following two independent questions. a. MM Corporation is considering several proposed investments for the coming budget year. MM produces electrical apparatus for industrial complexes....
-
What are the differences between a friend function and a member function?
-
Consider the following class declaration: class RQ1 { private: char * st; // points to C-style string public: RQ1() { st = new char [1]; strcpy(st,""); } RQ1(const char * s) {st = new char [strlen(s)...
-
What doesnt a derived class inherit from a base class?
-
Catherine Rampell is an economics writer for the Washington Post. In an article in 2023, she observes that the average U.S. tariff rate on mens underwear is 11.5 percent. The average rate on womens...
-
An opinion column in the Wall Street Journal argued that Americans enjoy comparative advantages in [service] sectors such as construction and engineering, but global trade in services is weighed down...
-
An article in the Wall Street Journal explained that despite rising national security tensions between the United States and China in 2023, trade between the two nations was rising. China is a...
Study smarter with the SolutionInn App