Error C3867

hi Guys when i'm trying to compile this code for some reason it wont refere to my class when i try and call it in main??

I am now totally lost with it so any help would be most appreciated

#include <iostream>
using namespace std;

class cteams
{
private:
static const char f_team1 , f_team2 , f_team3 ,f_team4 ;
int f_points_for_team1, f_points_for_team2, f_points_for_team3, f_points_for_team4;

public:
cteams (int startscore = 0);
int set_team1_score (int);
void set_team2_score (void);
void set_team3_score (void);
void set_team4_score (void);



};
cteams::cteams (int)
{

}

int cteams::set_team1_score (int startscore)
{
f_points_for_team1 = startscore;
}
void cteams::set_team2_score (void)
{
f_points_for_team2 = 0;
}
void cteams::set_team3_score (void)
{
f_points_for_team3 = 0;
}
void cteams::set_team4_score (void)
{
f_points_for_team4 = 0;
}


int main()
{
int start;
cteams score (start);
cout << "Hey team 1 score is " <<score.set_team1_score << endl;

system ("pause");
}


thanks in advance guys
Please use [code][/code] tags

in this line: cout << "Hey team 1 score is " <<score.set_team1_score << endl; you are using set_team1_score as a variable but it is a function
Hey Bazzy thanks for the help their. So I'm using it as a variable and not a function, I'm sure this will sound soo silly but How do i convert from a variable to a function then?

thanks so much for your help i have spent hours on this
ad parentheses and arguments:
score.set_team1_score ( /*the parameter you defined was: int startscore so give it a value*/ )
I gave it a value in the public class int startscore = 0 woudl i have to give it a value further down?
Once I put score.set_team1_score () it now says that int

cteams::set_team1_score (int startscore)
{
f_points_for_team1 = startscore;
}

must return a value??
It was declared as int set_team1_score (int); so it must return a value.
If you don't want to return a value, use void as return type but if you do so, cout won't display any value.
I think you want to return f_points_for_team1 after assigning it a new value
Last edited on
I have got totally lost with this now LOL. as you can probably guess im very new to coding!!

what are your views on a slightly different take on this

#include <iostream>
using namespace std;

class cteams
{
private:
static const char f_team1 [10], f_team2 [10], f_team3 [10],f_team4 [10];
int f_points_for_team1, f_points_for_team2, f_points_for_team3, f_points_for_team4;
public:
cteams (int);
int set_team1_score (){return (f_points_for_team1);}
int set_team2_score (){return (f_points_for_team2);}
int set_team3_score (){return (f_points_for_team3);}
int set_team4_score (){return (f_points_for_team4);}
};

cteams::cteams (int TheScore)
{
f_points_for_team1 = TheScore;
f_points_for_team2 = TheScore;
f_points_for_team3 = TheScore;
f_points_for_team4 = TheScore;
}


int main()
{
cteams team1 (0);
cteams team2 (0);
cteams team3 (0);
cteams team4 (0);

cout << "Team 1 Begins with " << team1.set_team1_score () << " Team 2 Begins with " << team2.set_team2_score () << endl;

system ("pause");
}

I think that should work but is that a propperly coded class with a constructor in? as im just never sure
I think you are messing a bit with setter and getter functions,
to have a good interface for your class the functions should be like these:
1
2
3
4
5
6
7
8
9
10
11
12
13
//Prototypes
void set_team1_score ( int );
int get_team1_score ();

//Bodies
void cteams::set_team1_score ( int newScore)
{
    f_points_for_team1 = newScore;
}
int cteams::get_team1_score ()
{
    return f_points_for_team1;
}


The constructor is fine, you can also have an initializer list on it:
1
2
3
4
5
cteams::cteams (int TheScore):
    f_points_for_team1 ( TheScore ), f_points_for_team2 ( TheScore )
    f_points_for_team3 ( TheScore ), f_points_for_team4 ( TheScore )
{
}


Notice that the prefix 'f' you used for names on the ungarian notation may mean 'float' or 'flag' but your variables are integers and C strings
How would you perhaps go about incorporating txt in to this class? as I want it to call a name for a team. and Bazzy your a diamond thanks buddy I have managed to finish the class to call back numbers now just need to sort the txt.

Any help most appreciated thanks guys
#include <string> and then you will be able of using std::string.
Create variables of that type and do what you need
eg:
1
2
3
4
5
string team1_name;

cteam ( const string &name ) : team1_name ( name )
{
}
As silly as this probably sounds, would you be able to elaborate alittle more on this? would I incorporate this in to my class? perhaps at the begining of the class? and write it in very much the same way as I have written the rest of the class? and thanks again Bazzy, it's much appreciated this help
The thing is I want my program to ask the user to enter a team name, anything he wants to call a team, and then the program takes this data and stores it in the new class i have built and I can call upon it when ever i choose if you get me? I have managed to do that with the numbers just cant seem to get it to implement text. Thanks again
Just create string variables as you created the ints for scores.
To get input, do something like this:
1
2
3
4
5
cteam team1;
string input;
cout << "What name you want for team 1? ";
getline ( cin, input );
team1.set_name ( input );
Where set_name may be implemented like this:
1
2
3
4
void cteam::set_name( const string & newName )
{
    name = newName; // replace name with whatever symbol you used for the member to hold the string
}
Here is the code so far. I am assuming you mean create string variables like i did for the scores, would they be int? or something else? and Would I be laying out Set_Name like the same as I did for my set_team_scores etc?? just a tad confused still but I am getting their LOl thanks so much, My brain is on over drive with this

#include <iostream>
#include <string>
using namespace std;

class cteams
{
private:
char f_team1 [30], f_team2 [30], f_team3 [30],f_team4 [30];
int f_points_for_team1, f_points_for_team2, f_points_for_team3, f_points_for_team4;
public:
cteams (int);
void set_team1_score (int),set_team2_score (int),set_team3_score (int),set_team4_score (int);
int get_team1_score (),get_team2_score (),get_team3_score (),get_team4_score ();

};

void cteams::set_team1_score (int StartScore)
{
f_points_for_team1 = StartScore;
}
int cteams::get_team1_score()
{
return (f_points_for_team1);
}



I haven't included all my code as don't want to bore you but would i implement the string in to the class very much the same way as I have done here with the scores?
Yes, however, don't use char ...[##], just use string ... like this:

string _team1, team2; //...
#include <iostream>
#include <string>
using namespace std;

class cteams
{
private:
string f_team1, f_team2, f_team3,f_team4;
int f_points_for_team1, f_points_for_team2, f_points_for_team3, f_points_for_team4;
public:
cteams (int);
void set_team1_score (int),set_team2_score (int),set_team3_score (int),set_team4_score (int);
int get_team1_score (),get_team2_score (),get_team3_score (),get_team4_score ();
void set_name (string);

};
void cteams::set_name (const string &newName)
{
string f_team1 = newName;
}

int main()
{

cteams teamscore (0);
cteams team1;
string input;
cout << "Enter a name here ";
getline (cin, input);
team1.set_name (input);
cout << "Team 1 Begins with " << teamscore.get_team1_score () << " Team 2 Begins with " << teamscore.get_team2_score () << endl;

system ("pause");
}

these are the 2 main chunks of my code, the problem im having here is it's saying overload member function not found?? and no appropriate default constructor?? this is getting more and more confusing but I'm getting their with much appreciated help from you guys!!
Declaration and body arguments don't match:
1
2
3
4
5
6
void set_name (string); // type: string

void cteams::set_name (const string &newName) // type: const string &
{
string f_team1 = newName;
}
Bazzy once again, I honestly cannot thank you enough!! It's great to know their are people actually out there willing to help others!
I know I probably sound like a total noob but where others would point and laugh you actually help, Had bad experiences on other forums!!

I just want you to know it's most appreciated!! So thank you.
Just think that everyone once didn't know how to program,
If someone in this forum gives you bad answers, remind him this: http://www.cplusplus.com/forum/articles/1295/#msg4410
Topic archived. No new replies allowed.