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

I am working on my Resistor.cpp file (I have the Main.cpp and the Resistor.h fil

ID: 3527371 • Letter: I

Question

I am working on my Resistor.cpp file (I have the Main.cpp and the Resistor.h files completed). Using the below setter function, how to i write a getter function that returns the member variable rather than setting the argument /to/ the member variable?

#include<iostream>

#include<iomanip>

#include<string>

using namespace std;


void Resistor::setNom(double Nom, bool fncheck){

nom=n;

if(fncheck){

cout<<"Set Nom was called"<<endl;

}

}

Resistor::Resistor(double res, double tol, string N, bool c)

{

Nom = res;

Tol = tol;

Name = N;

if(c){

cout<<"constructor was called"<<endl;

}

}


How do I write a getter for this setter function? I need it to return the member variable rather than setting the argument to the member variable. Please help.....??

Explanation / Answer

//If I understnad you correctly, you want help with mutators. double Resistor::getNom(){return Nom;} double Resistor::getTol(){return Tol;} double Resistor::getName(){return Name;}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote