i have been working on this for some time now and i get an error message that says "Could not find a match for 'vector<int>::vector(const int, const int, const int)' "
heres my code.
#include<u:\C Plus\LVP\gui_top.h>
#include<u:\C Plus\LVP\vector.h>
//--------------------------------------------------------------------------------
class ButtonClass {
public:
ButtonClass(String Text, int X1,int Y1, int X2, int Y2);
void Paint();
bool IsHit(int x, int y);
private:
int MyX1, MyY1, MyX2, MyY2;
String MyText;
};
//--------------------------------------------------------------------------------
ButtonClass::ButtonClass(String Text, int X1, int Y1, int X2, int Y2)
: MyText(Text), MyX1(X1), MyY1(Y1), MyX2(X2), MyY2(Y2)
{
}
//--------------------------------------------------------------------------------
void ButtonClass::Paint()
{
SetColor(BLACK);
SetFillColor(RED);
FilledRectangle(MyX1, MyY1, MyX2, MyY2);
gotoxy((MyX1+MyX2)/2, 5+(MyY1+MyY2)/2);
SetTextColor(BLUE);
SetTextSize(20);
SetTextFont("Arial");
DrawCenteredText(MyText);
}
//--------------------------------------------------------------------------------
bool ButtonClass::IsHit(int x, int y)
{
return (x>=MyX1&&x<=MyX2&&y>=MyY1&&y<=MyY2);
}
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
class GridClass {
public:
GridClass();
void Paint();
void MouseClick(int x, int y);
void InitGrid();
void Title();
private:
const int GridDimension; // # of Rows/columns in grid
// Constants for board; must all differ
const int Empty, Player1, Player2;
vector<int> Board; // Uses above constants
int Player, Player1Row, Player1Col, Player2Row, Player2Col;
bool GameOver;
int BoxSize; // Pixels per box
int LeftMargin; // Pixels from left
int TopMargin; // Pixels from top
void XYToRowCol(int x, int y, int &Row, int &Col);
void MarkBox(int Row, int Col, int BoxContents);
ButtonClass QuitButton;
ButtonClass RestartButton;
ButtonClass Column1Button;
};
//--------------------------------------------------------------------------------
GridClass::GridClass()
: GridDimension(10),
Empty(0), Player1(1), Player2(2),
Board(GridDimension,GridDimension,Empty),
GameOver(false),
BoxSize(GetMaxY()/2/GridDimension), // Fill half of y-dimension
LeftMargin((GetMaxX()-BoxSize*GridDimension)/2),
TopMargin(GetMaxY()/4),
QuitButton(" I Quit! ",10,10,100,40),
RestartButton(" Restart ", 100,10, 190,40),
Column1Button(" Column 1 ",((GetMaxX()-BoxSize*GridDimension)/2),((GetMaxY()/4)-40),(((GetMaxX()-BoxSize*GridDimension)/2)+90),(((GetMaxY()/4)-40)+5))
{
}
//--------------------------------------------------------------------------------
void GridClass::InitGrid()
/* Post: Grid initialized for a new game */
{
GameOver=false;
for (int Row=0; Row<GridDimension; Row++)
for (int Col=0; Col<GridDimension; Col++)
Board[Row][Col]=Empty;
}
//--------------------------------------------------------------------------------
void GridClass::XYToRowCol(int x, int y, int &Row, int &Col)
/* Post: Row and Column corresponding to x, y returned,
or -1 for if x, y is not on the board */
{
int DistFromLeft=x-LeftMargin;
Col=(DistFromLeft+BoxSize)/BoxSize-1;
int DistFromTop=y-TopMargin;
Row=(DistFromTop+BoxSize)/BoxSize-1;
if(Col<0||Col>=GridDimension||Row<0||Row>=GridDimension)
{
Row=-1;
Col=-1;
}
}
//--------------------------------------------------------------------------------
void GridClass::MarkBox(int Row, int Col, int BoxContents)
/* Post: Row, Col box in appropriate color */
{
SetColor(YELLOW); // For outline
SetFillColor(WHITE);
if (BoxContents==Player1)
SetFillColor(BLACK);
else if (BoxContents==Player2)
SetFillColor(RED);
FilledRectangle(Col*BoxSize+LeftMargin, Row*BoxSize+TopMargin,
(Col+1)*BoxSize+LeftMargin,
(Row+1)*BoxSize+TopMargin);
}
//--------------------------------------------------------------------------------
void GridClass::MouseClick(int x, int y)
{
int Row, Col;
if (QuitButton.IsHit(x,y))
{
GameOver = true;
if(MessageBoxYN("Are you sure you want to quit?", "Quit button clicked")==1)
PostQuitMessage(0);
else
InitGrid();
} //if QuitButton
else
if (RestartButton.IsHit(x,y))
{
InitGrid();
Paint();
}
else
{
XYToRowCol(x, y, Row, Col);
if((Row!=-1 && Col!=-1 && Board[Row][Col]!=Player1 && Board[Row][Col]!=Player2 && GameOver==false))
{
if ((Board[Row][Col]==Empty)&&(Player=1))
Board[Row][Col]=Player1;
else if ((Board[Row][Col]==Empty)&&(Player=2))
Board[Row][Col]=Player2;
} //if invalide move
else
MessageBeep(-1);
}
}
//------------------------------------------------------------------------------
void GridClass :: Title()
{
SetTextFont("Times New Roman");
SetTextColor(RED);
SetTextSize(40);
gotoxy(GetMaxX()/2, GetMaxY()/10);
DrawCenteredText("Connect Four");
}
//-------------------------------------------------------------------------------
void GridClass::Paint()
{
QuitButton.Paint();
RestartButton.Paint();
Column1Button.Paint();
Title();
SetColor(BLACK);
int Row, Col;
// Draw lines
for (Col=0; Col<=GridDimension; Col++)
Line(LeftMargin+Col*BoxSize, TopMargin,
LeftMargin+Col*BoxSize,
TopMargin+GridDimension*BoxSize);
for (Row=0; Row<=GridDimension; Row++)
Line(LeftMargin, TopMargin+Row*BoxSize,
LeftMargin+GridDimension*BoxSize,
TopMargin+Row*BoxSize);
// Color in boxes
for (Row=0; Row < GridDimension; Row++)
for (Col=0; Col<GridDimension; Col++)
MarkBox(Row,Col,Board[Row][Col]);
// Display results
SetTextSize(24);
if (GameOver==true)
{
gotoxy(20,GetMaxY()-100);
DrawText("Game over! Score = ");
}
}
//------------------------------------------------------------------------------
class GuiClass {
public:
GuiClass();
void GuiMouseClick(int x, int y); //Action if mouse click
void GuiPaint(); //Repaint the entire window
String Title(); //Return the title for the Window
private:
};
//---------------------------------------------------------------------------
GuiClass::GuiClass()
{
}
//---------------------------------------------------------------------------
String GuiClass::Title()
{
return ("Connect Four");
}
//---------------------------------------------------------------------------
void GuiClass::GuiMouseClick(int x, int y)
{
}
//---------------------------------------------------------------------------
void GuiClass::GuiPaint()
{
}
//---------------------------------------------------------------------------
#include <u:\C PLus\LVP\gui_bot.h>
your help is greatly appreciated