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;}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.