hi all,
i'm learning the book "Teach Yourself Visual C++ 6 in 21 days" , and i'm in Chapter 16 - Creating Your Own Classes and Modules . I did everything like it said but i've an error. This Static Library project has 2 classes , 1 class , called CLine , is added from other project and 1 class , called CModArt , is added in this project .
So this is the code to creat new line in CModArt class :
Code:
void CModArt::NewLine()
{
int lNumLines;
int lCurLine;
int nCurColor;
UINT nCurWidth;
CPoint pTo;
CPoint pFrom;
//Normalize the rectangle before determining the width and height
m_rDrawArea.NormalizeRect();
//Get the area width and height
int lWidth = m_rDrawArea.Width();
int lHeight = m_rDrawArea.Height();
//Determine number of parts to this squiggle
lNumLines = rand() % 100;
//Are there any part in squiggle
if (lNumLines > 0)
{
//Determine color
nCurColor = rand() % 8;
//Determine the pen width
nCurWidth = (rand() % 8) + 1;
//Determine the start point for the squiggle
pFrom.x = (rand() % lWidth) + m_rDrawArea.left;
pFrom.y = (rand() % lHeight) + m_rDrawArea.top;
//Loop through number of sequents
for (lCurLine=0; lCurLine<lNumLines; lCurLine++)
{
pTo.x = ((rand() % 20) - 10) + pFrom.x;
pTo.y = ((rand() % 20) - 10) + pFrom.y;
//Creat a new line
//CLine *pLine = new CLine(pFrom, pTo, nCurWidth, m_crColors[nCurColor]);
CLine *pLine = new CLine(pFrom, pTo, m_crColors[nCurColor]);
try
{
//try to add new line
m_oaLines.Add(pLine);
}
//Check did we run into memory exception
catch (CMemoryException *perr)
{
//Notice user the message
AfxMessageBox("Out of memory", MB_ICONSTOP | MB_OK);
//Did we creat a new line
if (pLine)
{
delete pLine;
pLine = NULL;
}
//Delete the exception
perr->Delete();
}
//Set the starting point to the end point;
pFrom = pTo;
}
}
}
and this is the error :
...\ModArt.cpp(82) : error C2065: 'CLine' : undeclared identifier
and this is the 82 line :
Code:
CLine *pLine = new CLine(pFrom, pTo, m_crColors[nCurColor]);
Thanx 4 all ur helps!