Can anyone point out why I am getting these errors two errors.

#include <string>
#include <iostream>
#include <fstream>
#include <iomanip>


using namespace std;

#include "playerType.h"

playerType::playerType(string first, string last, int num, string pos)

    : personType(first, last)
{
    playerNum = num;
    playerPos = pos;
    
} // end function playerType

void playerType::setPlayerNum(int num)
{
    try                    //Exception Handling
    {
        if(num < 0 )
            throw num;

        playerNum = num;
    }
    catch (int num)
    {
        cout << "Exception: Player's number must be positive. ";
    }

} //end function setPlayerNum

int getNum()
{
    return playerNum;       //Line (38)
} //end function getNum

void playerType::setPlayerPos(string pos)
{
    
    try                    //Exception handling
    {
        if (pos.length() > 2)
            throw string("Player's position must be PG, SG, G, SF, PF, F,, FC or C!");
        playerPos = pos;
    }
    catch (string str)
    {
        cout << "Exception handler: " << str << endl << endl;
    }
} //end function setPlayerPos

string getPos()
{
    return playerPos;          //line (58)
} //end getNum function

void playerType::print()
{
    personType::print();
    cout << "Player's Number: " << playerNum << endl
        << "Player's Position: " << playerPos << endl << endl;
} //end function print


void playerType::printFile(ostream& outF)
{
    outF << left;
    outF << setw(14) << getFirstName() << "   ";
    outF << setw(4) << getNum();
    outF << setw(5) << getPos();
}

ERROR

playertype.cpp(38) : error C2065: 'playerNum' : undeclared identifier
playertype.cpp(58) : error C2065: 'playerPos' : undeclared identifier

Recommended Answers

All 4 Replies

I imagine that those are member functions and their definitions need to be prefixed with playerType:: .

int getNum()

You didn't put them in the class int playerType::getNum()

how i can overcome this <iomanip> error

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.