zprestaz
asked on
text-Box Long
Hi boys,
i've realized a class named CasellaInt. This class check that the kind of data on input is of Int type. This class run well.
After i have realized the class CasellaLong. This class check that the kind of data on input is of Long type. But when i try to use it, i see this error on compilation: "
`CasellaLong' undeclared (first use this function)" "(Each undeclared identifier is reported only once for each function it appears in.)"
I don't know why.
I use the object of this 2 class in the same function,and both the header file are included.
Help me please
These are the 2 file.cpp:
**********CasellaInt.cpp** ********** ***
// CasellaInt.cpp
#include <cmath>
#include "CasellaInt.h"
//controllo specifico per la suddetta classe
void CasellaInt::isValid()
{
bool esito=true;
errorMsg=string();
int start = ( ( dato.at(0) == '-' ) ? 1 : 0 ); //da dove deve partire se c'è il segno meno
for (int i=start; i<dato.size(); i++)
if ( !isdigit( dato.at(i) ) )
{
errorMsg= "Il dato inserito non e' un numero intero";
esito=false;
break;
}
if (!esito)
dato = errorDato;
}
//costruttore
CasellaInt::CasellaInt(str ing mr, string dd, string ec, string ed="")
: Casella(mr,dd,ec,"")
{
errorDato = ed;
}
//restituzione dato come numero
int CasellaInt::getDato()
{
return atoi( dato.c_str() ); //conversione stringa vecchio stile C
}
//restituzione dato come stringa
string CasellaInt::getDatoString( ){
return dato;
}
**********end of CasellaInt.cpp***********
********CasellaLong.cpp*** ********** *
// CasellaLong.cpp
#include <cmath>
#include "CasellaLong.h"
//controllo specifico per la suddetta classe
void CasellaLong::isValid()
{
bool esito=true;
errorMsg = string();
for (long i=0; i<dato.size(); i++)
if ( !isdigit( dato.at(i) ) )
{
errorMsg= "Il dato inserito non e' un numero in formato corretto";
esito=false;
break;
}
if (!esito)
dato = errorDato;
}
//costruttore
CasellaLong::CasellaLong(s tring mr, string dd, string ec, string ed="")
: Casella(mr,dd,ec,"")
{
errorDato = ed;
}
//restituzione dato come numero
long CasellaLong::getDato() {
return atol( dato.c_str() ); //conversione stringa vecchio stile C
}
//restituzione dato come stringa
string CasellaLong::getDatoString (){
return dato;
}
*************end of CasellaLong.cpp*********** *******
i've realized a class named CasellaInt. This class check that the kind of data on input is of Int type. This class run well.
After i have realized the class CasellaLong. This class check that the kind of data on input is of Long type. But when i try to use it, i see this error on compilation: "
`CasellaLong' undeclared (first use this function)" "(Each undeclared identifier is reported only once for each function it appears in.)"
I don't know why.
I use the object of this 2 class in the same function,and both the header file are included.
Help me please
These are the 2 file.cpp:
**********CasellaInt.cpp**
// CasellaInt.cpp
#include <cmath>
#include "CasellaInt.h"
//controllo specifico per la suddetta classe
void CasellaInt::isValid()
{
bool esito=true;
errorMsg=string();
int start = ( ( dato.at(0) == '-' ) ? 1 : 0 ); //da dove deve partire se c'è il segno meno
for (int i=start; i<dato.size(); i++)
if ( !isdigit( dato.at(i) ) )
{
errorMsg= "Il dato inserito non e' un numero intero";
esito=false;
break;
}
if (!esito)
dato = errorDato;
}
//costruttore
CasellaInt::CasellaInt(str
: Casella(mr,dd,ec,"")
{
errorDato = ed;
}
//restituzione dato come numero
int CasellaInt::getDato()
{
return atoi( dato.c_str() ); //conversione stringa vecchio stile C
}
//restituzione dato come stringa
string CasellaInt::getDatoString(
return dato;
}
**********end of CasellaInt.cpp***********
********CasellaLong.cpp***
// CasellaLong.cpp
#include <cmath>
#include "CasellaLong.h"
//controllo specifico per la suddetta classe
void CasellaLong::isValid()
{
bool esito=true;
errorMsg = string();
for (long i=0; i<dato.size(); i++)
if ( !isdigit( dato.at(i) ) )
{
errorMsg= "Il dato inserito non e' un numero in formato corretto";
esito=false;
break;
}
if (!esito)
dato = errorDato;
}
//costruttore
CasellaLong::CasellaLong(s
: Casella(mr,dd,ec,"")
{
errorDato = ed;
}
//restituzione dato come numero
long CasellaLong::getDato() {
return atol( dato.c_str() ); //conversione stringa vecchio stile C
}
//restituzione dato come stringa
string CasellaLong::getDatoString
return dato;
}
*************end of CasellaLong.cpp***********
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER