why the program not returning the value of count?

0 votes
asked Aug 11, 2018 by anonymous
#include<iostream>

using namespace std;

struct node

{

  int prn;

  char name[10];

  node *next;

};

class club

{

  node *start;

public:

    club ()

  {

    start = NULL;

  }

  void add_pre ();

  void add_sec ();

  void add_mem ();

  void del_pre ();

  void del_sec ();

  void del_mem ();

  int count ();

  void display ();

};

void

club::add_pre ()

{

  node *temp;

  temp = new node;

  temp->next = NULL;

  cout << "\nenter name of president: ";

  cin >> temp->name;

  cout << "\nEnter prn of president: ";

  cin >> temp->prn;

  if (start == NULL)

    temp = start;

  else

    {

      temp->next = start;

      temp = start;

    }

}

int

club::count ()

{

  int count = 0; // Initialize count

  struct node *current = start; // Initialize current

  while (current != NULL)

    {

      count++;

      current = current->next;

    }

  return count;

}

int

main ()

{

  club c;

  c.add_pre ();

  c.count ();

}

1 Answer

0 votes
answered Aug 13, 2018 by H├ęctor Murcia Forero (180 points)
The method of class club, called count, is returning a value equals to zero, but it's not shown.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...