dimanche 30 juillet 2017

"Error: void value not ignored as it ought to be" - Understanding the error and trying to overcome it

Following is my code snippet.The error occurs in the display_results() method.

    class results
    {
    public:
        bool majority;
        int major_element = 0;

    void show_results()
        {
            if (majority)
            {
                cout<<"Majority found "<<major_element;
            }

            else
                cout<<"No majority element found";
        }
    };
void display_results(results* p, int number_of_testcases)
    {
        for(int i = 0; i<number_of_testcases;i++)
        {
          //Error occurs in next line  
         *p[i].show_results();
        }
    }

Can anyone explain me why is this happening?

Aucun commentaire:

Enregistrer un commentaire