Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Exercise A: The objective of this exercise is to help you in understanding how C + + objects are shown on a memory diagram, and
Exercise A:
The objective of this exercise is to help you in understanding how C objects are shown on a memory
diagram, and how a member function of a class uses the this pointer to access an object associated with a
particular function call.
What to Do:
Download files cplxcpp cplxh and labExA.cpp from the DL and draw AR diagrams for: point
one and point two.
For this exercise you just need to draw the diagrams. However, if you want to compile and run it from
command line, you should have all of the given files in the same directory and from that directory you should
use the following command to compile and create an executable:
gWall cplxcpp labExA.cpp
Please notice that you shouldnt have the header file names in this command.
What to Submit:
Submit your diagram as part of your lab report.
cplxh:
#ifndef cplxh
#define cplxh
class Cplx
public:
Cplx: realM imagM
Cplx double r double i;
double getRealPart const;
double getImaginaryPart const;
void setRealPartdouble arg;
void setImaginaryPartdouble arg;
Cplx addconst Cplx& otherconst;
Cplx subtractconst Cplx otherconst;
private:
double realM;
double imagM;
;
#endif cplxh
cplxcpp:
#include cplxh
Cplx::Cplxdouble real double imag : realMreal imagMimag
point one
double Cplx::getRealPart const
return realM;
double Cplx::getImaginaryPart const
return imagM;
void Cplx::setRealPartdouble arg
realM arg;
void Cplx::setImaginaryPartdouble arg
imagM arg;
point two
LabExA.cpp:
#include cplxh
void globalprintconst Cplx& n;
int mainvoid
Cplx num;
numsetRealPart;
Cplx num;
numsetImaginaryPart;
return ;
I included the AR diagram I made, please tell me if it's corect or not.Point :
AR
main
main
Point:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started