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
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
1 Answer
0
votes
answered
Aug 13, 2018
by
Héctor Murcia Forero
(
220
points)
The method of class club, called count, is returning a value equals to zero, but it's not shown.
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
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.
...