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
-
Calculate the number of disintegrations per second that one would expect from a 1.9-g sample of 226 88 Ra. What is the activity of this sample in curies?
-
Economists treat profits as a( n )________ left to the entrepreneur after ________, , and___________ have been paid.
-
9. Roy Watson bought vacuum cleaners from T & F Distributing Co. and then resold them door-to-door. He was an independent contractor. Before hiring Watson, the president of T & F checked with two...
-
Warranties Selzer Equipment Company sold 500 Rollomatics during 2010 at $6,000 each. During 2010, Selzer spent $30,000 servicing the 2-year warranties that accompany the Rollomatic. All applicable...
-
Informat Use the following information for the next 2 questions: ion On January 1, 2021, Opal Company had the following general borrowings. A part of the proceeds was used to finance the construction...
-
Given the following project network and baseline information below, complete the form to develop a status report for the project at the end of period 4 and the end of period 8. 0 A 2 0 2 2 2 O Task A...
-
1. Given the following information, what is thevalue of XYZ Corporation (in $ millions)?Common Stock: 12.30 million shares outstandingwith a $10 par value. Market price is $45.20/share.Bond Issue 2...
-
What are the pros and cons to automate employment benefits tasks and functions?
-
how can we review data in aws using oracle database ? explain all possiblities ?
-
Describe about Organizational Behavior and Management ? What are the three goals of organizational behavior? What are the 4 primary areas of organizational behavior?
-
During the month of September, the Bridge City Go-Kart Company had the following business activities: a. On September 1, paid rent on the track facility for six months at a total cost of $22,500. b....
-
Speaking candidly, what mistake(s) were made in the submission that warranted this Academic Integrity Violation?
-
Suppose a 5 - year, $ 1 , 0 0 0 bond with annual coupons has a price of $ 9 9 0 and a yield to maturity of 6 % . What is the bond's coupon rate?
-
Velshi Printers has contracts to complete weekly supplements required by fortysix customers. For the year 2018, manufacturing overhead cost estimates total $600,000 for an annual production capacity...
-
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?
-
A company maintains its fixed assets at cost. Depreciation provision accounts for each asset are kept. The following additions were made during the financial year ended 31 December 19X9: Machinery...
-
A Mavron ple owned the following motor vehicles as at 1 April 19X6: Mavyron ples policy is to provide at the end of each financial year depreciation using the straight line method applied on a...
-
(a) Identify the four factors which cause fixed assets to depreciate. (6) Which one of these factors is the most important for each of the following assets? (i) a gold mine, (ii) a motor lorry, (ii1)...
Study smarter with the SolutionInn App