- 🌊Yeram Kim🌊
- 홍익대학교 게임학부 게임소프트웨어학과 4학년 재학중😼
- 클라이언트 프로그래머 지망😊
21_가을_객체지향프로그래밍(2) 과제_지뢰찾기 모작
첨부파일 저장소
Game2D.cpp
void Game2D::run()
{.
.
.
while (*isLooping) {
clear();
if (GetNumberOfConsoleInputEvents(hStdi
.
.
.
위의 while문 루프를 탈출하면, HEAP CORRUPTION DETECTED 오류가 생긴다.
처음에는 isLooping 변수 문제인줄 알았느데, Game2D소멸자가 호출되면서 canvas배열 메모리가 해제되며 뭔가 충돌이 일어 난 다는 것을 알았다..ㅠㅠ 근데 왜 해제할때 충돌이 나는지 모르겠다. 걍 delte를 안하면 또 오류가 안생김!!ㅠㅠ왤까
Game2D의 함수를 아예 사용하지 않는 다는 것을 가정하고, virtual/override 를 사용해서 명시해뒀는데,
member function declared with 'override' does not override a base class member
라고 빨간 줄이 떴다.
내가 이 함수에게 적용한 다른 함수 같은 경우에는 오버라이드 된 자식의 함수의 반환형과 매개변수가 void였고, 부모 함수도 마찬가지였다. 그래서 부모함수는 무시하고 바로 자식 함수를 오버라이드 해라! 라고 간접적으로 컴파일러에게 알려주는 용으로 사용하였다.
하지만, Game2D에 선언한 함수는 오버라이드된 함수와 비교했을 때, 매개변수의 개수가 다르다는 점이 있다.
따라서 굳이 명시하지 않아도, 함수를 사용할 때 자동적으로 자식의 함수가 불러져 올 것이다.
그래서 매개변수의 갯수를 부모 함수와 같게 해주고 viirtual, override 키워드를 사용했는데
그래도 여전히 오류가 해결되지 않았다.
💡 키워드를 사용하지 않고 매개변수 갯수르 다르게 해줘서 오류는 해결했지만, 왜 키워드를 사용하면 오류가 날까?
알아봐야겠다!!
어떤 문제가 있는지는, 새 파일 불러다가 찬찬히 디버깅 해봐야 할 것 같다..ㅠ
우선 오늘은 너무 피곤..ㅠㅠ쉬고, 주말에 달려야집...
Filed.cpp
void Field::Compute_Near_Mine(const int _size,Field* _fields)
{
//전체필드만큼 반복문을 돌리고,
//\n인 필드와 *지뢰 필드는 계산에서 제외한다.
//배열에 초과하는 필드는 거른다.
for (int index = 1; index < _size + 1; index++)//배열 field 탐색
{
if (_fields[index-1].GetState() == STATE_SPOT || (index % 11==0 && index>=11)) continue;//지뢰 필드인 경우 탐색하지 않음.
for (int point = index - 1; point < index + 2; point++)// |i-1|i|i+1| i를 기준으로 둘레 탐색.
{
if (point % 11 == 0 && point>=11) continue;
int up = point - 11 * (point / 11);//11은 width+1 나중에 바꿔줄거임. 보기 쉽게.
int down = point + 11 * (point / 11);//11은 width+1 나중에 바꿔줄거임. 보기 쉽게.
if (point < 11)
{
up = 0;
down = point + 11 * (point / 11 + 1);
}
//1~size 범위에 만족하고 필드에 지뢰가 있으면.
if (up >= 1 && up < _size-11)
{
if (_fields[up - 1].GetState() == STATE_SPOT)
{
_fields[index - 1].Changestate(_fields[index - 1].GetState() + 1);
}
}
if (down >= 12 && down < _size)
{
if (_fields[down - 1].GetState() == STATE_SPOT)
{
_fields[index - 1].Changestate(_fields[index - 1].GetState() + 1);
}
}
if(_fields[point-1].GetState() == STATE_SPOT && point != index)
_fields[index - 1].Changestate(_fields[index - 1].GetState() + 1);
}
}
}
virtual/override 함수 사용 과정에서 override,virtula 명시했는데ㅠㅠ계속 빨간줄임..ㅠㅠ
Game2D.cpp
❌GetClickedField(mer);
if (mer.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED)
{
printf("left button press %d %d\n", mer.dwMousePosition.X, mer.dwMousePosition.Y);
GetClickedField(mer);
}
else if (mer.dwButtonState == RIGHTMOST_BUTTON_PRESSED)
{
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.