Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.
Login
Login
OnlineGDB Q&A
Questions
Unanswered
Tags
Ask a Question
Ask a Question
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 ();
}
urgent
Please
log in
or register to answer this question.
1 Answer
0
votes
answered
Aug 13, 2018
by
Hector Murcia Forero
(
220
points)
The method of class club, called count, is returning a value equals to zero, but it's not shown.
Please
log in
or register to add a comment.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...