16,471
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <stack>
using namespace std;
class abc
{
public:
static int a;
int b;
static void seta(int x);
static int geta();
};
int abc::a=0;
int abc::geta()
{
return a;
}
void abc::seta(int x)
{
a=x;
}
int main()
{
stack<abc> s;
abc a,b,c;
a.b=1;
a.seta(1);
b.seta(2);
b.b=2;
c.seta(3);
c.b=3;
s.push(a);
s.push(b);
s.push(c);
for (int i=0;i<3;i++)
{
cout<<s.top().geta()<<s.top().b<<endl;
s.pop();
}
}
这个代码是没有错误了,我自己测试了一下能用,但是当我将这代码复制到MFC上面就出现了问题#include "PointSet.h" // Added by ClassView
#include "ChessRule.h"
#include <stack>
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CFive_Chess_01Dlg : public CDialog
{
public:
CFive_Chess_01Dlg(CWnd* pParent = NULL); // standard constructor
.....
protected:
HICON m_hIcon;
....
private:
int time;
void ClearBroad();
int chess_color;
CPointSet pointset;
CImageList img;
CChessRule rule;
void DrawChesses(CPoint p,int Color);
void DrawBoard();
void push(int x,int y,int Color);
stack<int> s; //这里定义了一个...
};
#include "stdafx.h"
#include "Five_Chess_01.h"
#include "Five_Chess_01Dlg.h"
#include "PointSet.h"
#include "ChessRule.h"
#include "ChessStack.h"
#include <stack>
void CFive_Chess_01Dlg::OnLButtonUp(UINT nFlags, CPoint point)
{
stack<int> s;
// TODO: Add your message handler code here and/or call default
if(pointset.IsNullChess(point))
{
DrawChesses(point,chess_color);
if(rule.F_Win(point,chess_color))
MessageBox("你赢了");
else
{
if(F_WHITE==chess_color)
chess_color=F_BLACK;
else
chess_color=F_WHITE;
}
}
CDialog::OnLButtonUp(nFlags, point);
}