I want to check if the caller has passed a value for outOf
and if not then I want to use a default value. I did some research online and saw that you can use argc
to see how many variables are passed. I tried using that in the below code but I got the following error
Use of undeclared identifier 'argc'
How can I fix the below code?
#include "Mark.h"
#include <iostream>
using namespace std;
void Mark::set(int displayMode){
m_displayMode= displayMode;
}
void Mark:: set(double mark, int outOf){
m_mark= mark;
if ( int argc < 2){
m_outOf=1;
}else{
m_outOf=outOf;
}
}
void Mark:: Mark ::setEmpty(){
m_displayMode= DSP_UNDEFINED;
m_mark=-1;
m_outOf = 100;
}
bool Mark:: isEmpty()const{
bool result= true;
if((m_displayMode==DSP_UNDEFINED) && (m_mark==-1) && (m_outOf==100)){
result =true;
}else{
result = false;
}
return result;
}
main function
m2.setEmpty();
cout << "Setting m2 to the raw value of m1..." << endl;
m2.set(m1.rawValue());
cout << "done!" << endl;
cout << "m2: The mark is: ";
m2.set(DSP_ASIS);
m2.display() << endl;
cout << "m2: With the raw value of: ";
m2.set(DSP_RAW);
m2.display() << endl;
cout << "m2: And percentage value of: ";
m2.set(DSP_PERCENT);
m2.display() << endl;