Link to home
Start Free TrialLog in
Avatar of KimZeerip
KimZeerip

asked on

Need Help With Code

I am fairly new to C++ and was wondering if anyone could help me out debuggin this code....I am not real sure what to do.

#include<iostream.h>
#include<conio.h>
class ClubMember
{
  private:
    static int count;
    char name[20];
  public:
    ClubMember();
    ~ClubMember();
 };
int ClubMember::count = 0;
ClubMember::ClubMember(char name)
 {
    ++count;
    strcpy(name,name);
    cout<<"ClubMember #"<<count<<" created: ";
    cout<<name<<" has joined the club"<<endl;
 }
ClubMember::~ClubMember(char name)
  {
    --count;
    cout<<name<<" has left the club"<<endl;
    cout<<count<<" ClubMembers left"<<endl;
  }
void main()
{
  {
    cout<<"This program shows five club members"<<endl<<"joining, then leaving, the club"<<endl;
    ClubMember club[5] = {ClubMember("Jim"),ClubMember("Tom"),
         ClubMember("Julie"),ClubMember("Jane"),ClubMember("Kate")};
  }
  getch();
}
Avatar of jhance
jhance

I see no statement of any problem.  What part of this code is giving you trouble?  What part don't you understand?

Can I assume that YOU wrote this code?
Avatar of KimZeerip

ASKER

When I compile I have 7 errors which are all the same stating : "No constructor could take the source type, or constructor overload resolution was ambiguous"

I am not sure what this means
Avatar of jkr
>>I see no statement of any problem

ClubMember::ClubMember(char name)

jhance, like https://www.experts-exchange.com/cplusprog/Q.20288160.html (huh, another Kim?), I guess this is homework - the coding styles are too similar, and the task may have been "what is wrong with this code"...
jkr -- I don't know what your problem is, if you did not want to help me then you should have not added a comment...this is not homework, I am teaching myself C++ and it is an example file that came with the book and I am trying to figure it out!  Not everyone is as gifted as you I guess.  Sorry for trying to learn C++.....if anyone else is willing to help me learn C++ and figure this out, please add a comment or answer!  Thanks
jkr -- I don't know what your problem is, if you did not want to help me then you should have not added a comment...this is not homework, I am teaching myself C++ and it is an example file that came with the book and I am trying to figure it out!  Not everyone is as gifted as you I guess.  Sorry for trying to learn C++.....if anyone else is willing to help me learn C++ and figure this out, please add a comment or answer!  Thanks
I think jkr is concern that it appears that you have multiple login names, and posted back-to-back similar questions via multiple user id.

You'll find that jkr is one of the more well mannered expert in this topic area.

If you want us to help you, you need to supply as much information as you can.


Post the errors you get.  Post everything you know about the problem.
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ooops, 'strcpyn' sould be 'strncpy'...
When I compile that code...the output is

"This program shows five club members"<<endl<<"joining, then leaving, the club"

how can I write the code so that the user of the program can input data for the ClubMember # and name??
Figured it out on my own
In order to receive a refund, you have to show the answer before we can Delete or PAQ the question, as it stands now, it is no good for a PAQ.

BTW-I would also like to know which account you wish to keep, this one or KimHopper?

Regards,
ComTech
CS Admin @ EE
Dear KimZeerip

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "jkr"

comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points. The link to the Community Support area is: https://www.experts-exchange.com/commspt/

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner

BTW: Another part that was failing was:

ClubMember::ClubMember(char* name)
{
  strcpyn(name,name, 20); // you only have 20 chars

The scope of "name" is wrong. Either use another variable name or use "strncpy (this->name, name,20)" ...
Ooops, no - I am not gonna claim any points for "double account homework" questions...
- It was no homework
 - You are guilty of solving the problem
 - You found the duplicate account

My verdict:
The defendant will be sentenced to get his comment force-accepted!

<LOL>
Force accepted

** Mindphaser - Community Support Moderator **