getting errors golfer1 must have class type

#include <iostream>
#include <string>


class FrisbeeGolfer {
private:
string name;
double tosses;
double games;
double average;
double id;
public:
FrisbeeGolfer(string name, double tosses, double games, double average, double id) {
this->name = name;
this->tosses = tosses;
this->games = games;
this->average = average;
this->id = id;

void setName(string name);
void setTosses(double tosses);
void setGames(double games);
void setAverage(double average);
void setID(double id);
void addScore(double Tosses);

}
string getName() {
return name;
}
double getTosses() {
return tosses;
}
double getGames() {
return games;
}
double getID() {
id = rand() % 20;
if (id > 0)
return id;
}
double getAverage() {
return (tosses / games);
}
double getAddScore(double Tosses) {
games += 1;
if (Tosses > 0)
{
tosses += Tosses;
}
return Tosses;
}

};
#include <string>
#include <iostream>
#include "stdafx.h"
#include "FrisbeeGolfer.h"


using namespace std;

int main() {

string name;
double tosses;
double games;
double id;
double average;

FrisbeeGolfer golfer1(string name, double id, double tosses, double games, double average);

cout << "What is the name of the golfer?" << endl;
cin >> name;
cout << "How many games has " << name << " played total?" << endl;
cin >> games;
cout << "How many tosses were there for " << name << " total?" << endl;
cin >> tosses;



FrisbeeGolfer golfer2(name, id, tosses, games, average);

cout << "What is the name of the golfer?" << endl;
cin >> name;
cout << "How many games has " << name << " played total?" << endl;
cin >> games;
cout << "How many tosses were there for " << name << " total?" << endl;
cin >> tosses;



cout << "Golfer " << golfer1.getName() << ", ID #" << golfer1.getID() << ", has an average of " << golfer1.getAverage() << "." << endl;
cout << "Golfer " << golfer2.getName() << ", ID #" << golfer2.getID() << ", has an average of " << golfer2.getAverage() << "." << endl;


cout << "Please enter score of new game for Golfer " << golfer1.getName() << "." << endl;
cin >> tosses;
cout << "Please enter score of new game for Golfer " << golfer2.getName() << "." << endl;
cin >> tosses;



system ("pause");
return 0;
}
When creating an object you should not write the types before each argument.

 
FrisbeeGolfer golfer1(name, id, tosses, games, average);

Note that you need wait until you have given values to all the variables that are passed as argument before you create the object this way.
Last edited on
ok, thank you for the help.
Topic archived. No new replies allowed.