So, I currently work on an OOP flow chart project.
Point here is that I want to make sure that the program doesn't draw 2 shapes over each others "As well as for window boundaries", so I should give an IF CONDITION, such that within it, the Program draws in the interface !
Here's a part of my code.
case ADD_START:
pO->PrintMessage("Action: add start statement, Click anywhere in the drawing Area");
Statement*statS;
pIn->GetPointClicked(P);
if ( (for (int i = 0; i < NumOfFigures; i++)
{ //Test
i == NumOfFigures;
} )
&& (P.x>30) && (P.x< UI.width-(30+UI.ELLIPSE_R1)) && (P.y>2*UI.TlBrWdth+3)
&& (P.y<UI.height - (UI.StBrWdth+UI.ELLIPSE_R2)) )
{
statS=new Start();
statS->setPoint(P);
statS->DrawStatement(pO,pIn);
pStat[NumOfFigures] = statS;
NumOfFigures++;
}
break;
Here you can see that pStat is array of pointers to an abstract class Statement, however, I want to add the address of the shapes drawn at the run-time into that array of pointers, so that withing the if condition I could create a for loop to check upon each shape in that array with the boundaries of it as to check that P (which is a point)
P.x != pStat[NumOfFigure]->x;
But the problem here that it gives me an error for the for loop inside the if statement, saying that
ERROR : Expected an expression "
What should I do ?
if ( (for (int i = 0; i < NumOfFigures; i++), but why not just doing it the other way round?forstatement is just that, a statement, and can't ever be used as an expression which is whatifexpects as condition.forloop to traverse all those shapes, and put the boundaries check inside. You don't need to shout on me BTW, OK!for(int i = 0; i < NumOfFigures; i++) { i == NumOfFigures; }to be?