mimst71
Nouveau membre
J'ai tapé un morceau de prg et je ne comprend pas les erreurs. Sachan que LINE, RECTANGLE et CERCLE sont aussi définis dans une classe ressources.h et concernant le case je ne vois pas comment l'utiliser autrement.
CElement * CTP2suiteView::CreateElement()
{
CTP2suiteDoc* pDoc= GetDocument();
ASSERT_VALID(pDoc);
switch(pDoc->GetElementType())
{
case LINE: return new CLine(m_FirstPoint,m_SecondPoint,pDoc->GetElementWidth(),pDoc->GetElementColor());
case RECTANGLE: return new CRectangle(m_FirstPoint,m_SecondPoint,pDoc->GetElementWidth(),pDoc->GetElementColor());
case CERCLE: return new CCercle(m_FirstPoint,m_SecondPoint,pDoc->GetElementWidth(),pDoc->GetElementColor());
default: ;
}
}
Voici les erreurs qu'il me sort en compilant:
error C2065: 'LINE' : undeclared identifier
F:\TP2\TP2suiteView.cpp(139) : error C2051: case expression not constant
F:\TP2\TP2suiteView.cpp(140) : error C2065: 'RECTANGLE' : undeclared identifier
F:\TP2\TP2suiteView.cpp(140) : error C2051: case expression not constant
F:\TP2\TP2suiteView.cpp(141) : error C2065: 'CERCLE' : undeclared identifier
F:\TP2\TP2suiteView.cpp(141) : error C2051: case expression not constant
F:\TP2\TP2suiteView.cpp(143) : warning C4065: switch statement contains 'default' but no 'case' labels
Generating Code...
Error executing cl.exe.
CElement * CTP2suiteView::CreateElement()
{
CTP2suiteDoc* pDoc= GetDocument();
ASSERT_VALID(pDoc);
switch(pDoc->GetElementType())
{
case LINE: return new CLine(m_FirstPoint,m_SecondPoint,pDoc->GetElementWidth(),pDoc->GetElementColor());
case RECTANGLE: return new CRectangle(m_FirstPoint,m_SecondPoint,pDoc->GetElementWidth(),pDoc->GetElementColor());
case CERCLE: return new CCercle(m_FirstPoint,m_SecondPoint,pDoc->GetElementWidth(),pDoc->GetElementColor());
default: ;
}
}
Voici les erreurs qu'il me sort en compilant:
error C2065: 'LINE' : undeclared identifier
F:\TP2\TP2suiteView.cpp(139) : error C2051: case expression not constant
F:\TP2\TP2suiteView.cpp(140) : error C2065: 'RECTANGLE' : undeclared identifier
F:\TP2\TP2suiteView.cpp(140) : error C2051: case expression not constant
F:\TP2\TP2suiteView.cpp(141) : error C2065: 'CERCLE' : undeclared identifier
F:\TP2\TP2suiteView.cpp(141) : error C2051: case expression not constant
F:\TP2\TP2suiteView.cpp(143) : warning C4065: switch statement contains 'default' but no 'case' labels
Generating Code...
Error executing cl.exe.