Solved

text-Box Long

Posted on 2003-12-01
2
200 Views
Last Modified: 2010-04-02
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(string 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(string 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******************

0
Comment
Question by:zprestaz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Accepted Solution

by:
rstaveley earned 20 total points
ID: 9850822
Look at the top of CasellaLong.h and you'll see:

#ifndef CASELLAINT_H
#define CASELLAINT_H

This should probably be

#ifndef CASELLALONG_H
#define CASELLALONG_H

Otherwise, you'll not get the definitions if you've already included CasellaInt.h.
0
 

Author Comment

by:zprestaz
ID: 9850936
Tank you rstaveley, it was my fault
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question