Newsgroup: it.comp.lang.c++
Titolo: errore compilazione

Sto provando un'applicazione con visual c++.In particolare c'è una funzione 
che proprio non gira.Addirittura mi da qualcosa come 102 errori.La funzione 
è questa:
CLine * CDay10Doc::AddLine(CPoint ptFrom, CPoint ptTo)
{
 CLine *pLine = new CLine(ptFrom, ptTo);
 try
 {
  m_oaLines.Add(pLine);
  SetModifiedFlag();
 }
 catch (CMemoryException* perr)
 {
  AfxMessageBox("Out of memory", MB_ICONSTOP | MB_OK);
  if(pLine)
  {
   delete pLine;
   pLine=NULL;
  }
  perr->Delete();
 }
 return pLine;
}
Non riesco a capire perchè mi dà tutti quegli errori.A titolo descrittivo ve 
li posto ringraziando per l'attenzione:
Compiling...
day10Doc.cpp
c:\programmi\microsoft visual studio\myprojects\day10\day10doc.h(35) : error 
C2143: syntax error : missing ';' before '*'
c:\programmi\microsoft visual studio\myprojects\day10\day10doc.h(35) : error 
C2501: 'CLine' : missing storage-class or type specifiers
c:\programmi\microsoft visual studio\myprojects\day10\day10doc.h(35) : error 
C2501: 'AddLine' : missing storage-class or type specifiers
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(86) : 
error C2143: syntax error : missing ';' before '*'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(86) : 
error C2501: 'CLine' : missing storage-class or type specifiers
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(87) : 
error C2501: 'AddLine' : missing storage-class or type specifiers
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(88) : 
error C2065: 'pLine' : undeclared identifier
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(88) : 
error C2061: syntax error : identifier 'CLine'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2319: 'try' must be followed by a compound statement. Missing '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2317: 'try' block starting on line '90' has no catch handlers
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
error C2143: syntax error : missing ';' before '{'
C:\Programmi\Microsoft Visual Studio\MyProjects\day10\day10Doc.cpp(90) : 
fatal error C1003: error count exceeds 100; stopping compilation
Error executing cl.exe.
day10Doc.obj - 102 error(s), 0 warning(s)

 che proprio non gira.Addirittura mi da qualcosa come 102 errori.
Dicci qual'è la riga in cui viene riportato il primo errore.
E.

 cut...
Il metodo AddLine, usa dei parametri CPoint e restituisce un puntatore 
ad una istanza di CLine, creata appositamente nel metodo stesso.
Per cui il compilatore si lamenta per il fatto di non conoscere CLine 
e/o altre classi che vengono usate.
Dovresti includere gli header files dove sono state definite le classi 
coinvolte (#include "cline.h" oppure "cline.hpp" e/o "cpoint.h" o 
"cpoint.hpp").
Se il compilatore si lamenta della riga dove compare il 
catch(CMemoryException...) dovresti includere anche l'header file dove 
la classe CMemoryException viene definita.
Se la classe CDay10Doc è stata definita nell'header file 
(cday10doc.hpp?) che hai incluso nel tuo file .cpp che ci hai mostrato 
(come si dovrebbe fare normalmente) allora le inclusioni degli header 
file di definizione di CLine, CPoint ecc... vanno fatte nel file 
cday10doc.hpp.
Maurus

 CLine * CDay10Doc::AddLine(CPoint ptFrom, CPoint ptTo)
Non e' che ti sei dimenticato di mettere il punto e virgola dopo la
definizione di classe che viene subito prima di questa funzione,
magari in un file header?
Ciao,
Nicola

 ha scritto nel messaggio 
news:yrrNk.4398$8%.139@tornado.fastwebnet.it...

Il problema persiste.La riga incriminata è questa:
CLine * AddLine(CPoint ptFrom,CPoint ptTo);
Mi da questo errore:
c:\programmi\microsoft visual studio\myprojects\day10\day10doc.h(35) : error
C2501: 'CLine' : missing storage-class or type specifiers
Non so quale file.h includere.CLine è una classe che ho creato ex novo nel
progetto.

tonino ha scritto:

La riga in questione sembra corretta. Bisognerebbe vedere come hai 
dichiarato CLine.
E.

 
Dovresti includere l' header files dove è stata definita la classe 
coinvolta (#include "cline.h" oppure "cline.hpp").
 > CLine è una classe che ho creato ex novo nel
 > progetto.
Appunto..., dove hai creato questa classe?
Fisicamente, in quale file hai messo la sua definizione?
class CLine
{
public:
protected:
private:
};
Sarà quello il file da includere per non far lamentare il compilatore.
Se l'hai definita in un file sorgente .cpp, crea un file .h o .hpp e 
sposta lì la sua definizione.
Maurus