Ok, I have 3 static data members defined for a class "calculator" in a file ('calculator.h') how do initialize these for use?
The three data memberes are:
static float display
static float num1
static char command
i have tried putting them in the constructor like this:
float calculator::display = 0;
float calculator::num1 = 0;
char calculator::command = ' ';
it gives me these errors:
E:\School\CPS271\mp2\calculator.cpp(15) : error C2655: 'display' : definition or redeclaration illegal in current scope
E:\School\CPS271\mp2\calculator.cpp(15) : error C2655: 'num1' : definition or redeclaration illegal in current scope
E:\School\CPS271\mp2\calculator.cpp(15) : error C2655: 'command' : definition or redeclaration illegal in current scope
When I take off scope resolution it gives me these errors:
calculator.obj : error LNK2001: unresolved external symbol "private: static float calculator::display" (?display@calculator@@0MA)
calculator.obj : error LNK2001: unresolved external symbol "private: static float calculator::num1" (?num1@calculator@@0MA)
calculator.obj : error LNK2001: unresolved external symbol "private: static char calculator::command" (?command@calculator@@0DA)
Anyone have a clue??
Thanks again!
The three data memberes are:
static float display
static float num1
static char command
i have tried putting them in the constructor like this:
float calculator::display = 0;
float calculator::num1 = 0;
char calculator::command = ' ';
it gives me these errors:
E:\School\CPS271\mp2\calculator.cpp(15) : error C2655: 'display' : definition or redeclaration illegal in current scope
E:\School\CPS271\mp2\calculator.cpp(15) : error C2655: 'num1' : definition or redeclaration illegal in current scope
E:\School\CPS271\mp2\calculator.cpp(15) : error C2655: 'command' : definition or redeclaration illegal in current scope
When I take off scope resolution it gives me these errors:
calculator.obj : error LNK2001: unresolved external symbol "private: static float calculator::display" (?display@calculator@@0MA)
calculator.obj : error LNK2001: unresolved external symbol "private: static float calculator::num1" (?num1@calculator@@0MA)
calculator.obj : error LNK2001: unresolved external symbol "private: static char calculator::command" (?command@calculator@@0DA)
Anyone have a clue??
Thanks again!