I'm having trouble with this code in the implementation for my header file.
I keep getting error in line of code string SetCard::convert_symbol(Symbol s)
it keeps saying that it may not be redeclared outside of its class.
as well as:
error C2601: 'SetCard::convert_Symbol' : local function definitions are illegal
Any idea what could be causing this?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
string SetCard::convert_Symbol(Symbol s){
switch(s) {
case OVAL:
return"Oval";
break;
case SWIGGLES:
return"Swiggles";
break;
case DIAMOND:
return"Diamond";
break;
default:
cout << "Error! Invalid Symbol." << endl;
exit(1);
}
}
#ifndef SETCARD_
#define SETCARD_
#include <iostream>
#include <string>
usingnamespace std;
//new enum types
enum Color { RED, GREEN, PURPLE };
enum Symbol { OVAL, SWIGGLES, OVAL };
enum Shading { SOLID, STRIPED, OUTLINED } ;
//Class Definition
class SetCard {
public:
//Constructors----------------------------
//Default Constructor
SetCard();
//Inspectors------------------------------
//gets color of card
Color getColor() const;
//gets symbol on the card
Symbol getSymbol() const;
//gets shading of the card
Shading getShade() const;
//gets the numnber of symbols in the card
unsignedint getNumber() const;
//Mutators-------------------------------
//Sets color of card
void SetCard::setColor(Color &cardColor);
//Sets symbol of card
void SetCard::setSymbol(Symbol &cardSymbol);
//Sets shade of card
void SetCard::setShade(Shading &cardShade);
//Sets number of symbol in a card
void SetCard::setNumber(unsignedint numberofSymbol);
//converts Color type to string
string SetCard::convert_Color(Color c);
//converts Symbol type to string
string SetCard::convert_Symbol(Symbol s);
//converts Shading type to strin
string SetCard::convert_Shade(Shading sh);
//Facilitators------------------------------
//prints to screen
string SetCard::toString();
void output(ostream& out);
private:
Color cardColor_;
Symbol cardSymbol_;
Shading cardShade_;
unsignedint numberofSymbol_;
};
#endif
Based on the error (which you should have posted in your first post) and the fact that the little code snippet you provided is indented funny, I would say you're probably attempting to create a function definition within another function, which makes no sense.
from the header file to the implementation file. I've done the same method before on a previous homework and it ran fine which is why I don't understand what I'm doing wrong now.
here's the whole implementation code if it helps :)