-1

I already posted here but wanted to make a more clarified post, so i have my diplay function that displays linked list when the variable CurrentCapacity equals variable MaxCapacity in struct CourseData:

class CourseNode {
    private:
        CourseData elem;
        //
        CourseNode* next;

    public:
        CourseNode(CourseData elem) : elem(elem)
        {}  
        friend class Courses ;

};

class Courses {
    private:
        
        CourseNode *head;
    public:     
        Courses();
        ~Courses();
        void getCources();
        void addCoursesdata();
        bool empty() const;
        void removeFront();
        void addFront(const CourseData& elem);
        void loadData();
        void display() const;
        void viewFreeCourses() const;
        


struct CourseData {
    string CourseID, MaxCapacity, CurrentCapacity ;
    string CourseName, InstructorName, CourseSection, CourseLocation, ListOfStudents;
};

ostream& operator<<(ostream &os, const CourseData &data) {
    os << "("<<data.CourseName << ")";  
    return os;
}



void Courses::viewFreeCourses() const

{
    CourseNode *ptr=head;
    CourseData a;

    //cout<<"Head->";
    while(ptr!=NULL)
    {   
        if (ptr->stoi(elem.CurrentCapacity)==stoi(ptr->elem.MaxCapacity)) {
        cout<<ptr->elem<<endl; //"->";
        ptr=ptr->next;
    }
    }
    //cout<<"Null"<<endl;
}

But it outputs no member named 'stoi' in 'CourseNode', what could be the issue? Thanks in advance

Fantom
  • 1
  • 2
  • You haven't provided the definition of `CourseNode`, nor of `stoi`. There's no way we can know what's wrong with them. – Quentin Oct 06 '20 at 10:04
  • 1
    you don't have to post a new question, you can edit your old one – 463035818_is_not_an_ai Oct 06 '20 at 10:04
  • i edited it, can you check it, stoi() i think it is built in – Fantom Oct 06 '20 at 10:07
  • @Fantom, buit in where? `CourseNode` does not have any member method named `stoi`. – anastaciu Oct 06 '20 at 10:11
  • Well there is, indeed, no `stoi` inside `CourseNode`. Did you mean `stoi(ptr->elem.CurrentCapacity)` instead of `ptr->stoi(elem.CurrentCapacity)`? It also looks like you have `using namespace std;` lurking around, [please don't do that](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice). – Quentin Oct 06 '20 at 10:11
  • Impossible to answer without more detail. In particular, there are various `#include` directives that aren't show, and, apparently, a `using namespace std;`. – Pete Becker Oct 06 '20 at 14:03

1 Answers1

-1

You should write:

stoi(ptr->elem.CurrentCapacity)==stoi(ptr->elem.MaxCapacity)
Axe319
  • 4,255
  • 3
  • 15
  • 31