I am new to c++ but I am working on a project dealing with doing different operations with sets and one of them simply prints it out if the set is finite. SoS is the object being used which just stands for set of strings and has a vector of strings and a boolean as its data members. I created a function to check if the set is finite and I am trying to call it in my print function but i keep getting an error saying "no member named "isFinite." Heres what I have, any help is greatly appreciated.
void SoS::print() const{
if (m_vos.isFinite() == true){
for (int i = 0; i < m_vos.size(); i++){
cout << m_vos[i]<< endl;
}
}
else{
cout << "COMPLEMENT OF:"<< endl;
for (int i = 0; i< m_vos.size(); i++){
cout << m_vos[i]<< endl;
}
}
}
bool SoS::isFinite() const{
if (isfinite(m_vos.size()){
return true;
}
return false;
}
no member named "isFinite"or is it sayingno member named "isfinite"? In yourisFinitemethod you make a call toisfinite. AlsoisFinitedoesn't have any parameters. And if your first line of a method calls said method, you'll get an infinite recursion.m_vos? It looks like a member ofSoSbut doesn't appear to be a pointer. You need to callSoS::isFinite()on an object ofSoS, or you can call it from within another method ofSoS.m_voscould be a value-member, not all objects need pointers to use them.SoS, declared inSoS, it would need to be a pointer right? Unless it was a global?SoScontains a "vector of strings and a boolean as its data members". Sovector<string> m_vos;