Ok, I invented a class to pass an array of ints:
Code:
#include <windows.h>
#include <iostream>
#include <string.h>
#include <conio.h>
#include <fstream.h>
using namespace std;
class Keeper {
private:
SHORT zzx[5];
public:
Keeper() {zzx[0] = 0; zzx[1] = 0; zzx[2] = 0; zzx[3] = 0; zzx[4] = 0;}
Keeper(SHORT z, SHORT zz, SHORT zzz, SHORT zzzz, SHORT b) {zzx[0] = z; zzx[1] = zz; zzx[2] = zzz; zzx[3] = zzzz; zzx[4] = b;}
void Check(SHORT x) {zzx[x] = 1;}
void Uncheck(SHORT x) {zzx[x] = 0;}
void UncheckAll() {zzx[0] = 0; zzx[1] = 0; zzx[2] = 0; zzx[3] = 0; zzx[4] = 0;}
int IsChecked(SHORT x);
};
int Keeper::IsChecked(SHORT x) {
if(zzx[x] == 1)
return 1;
return 0;
}
Pritty elementary, no safety at all. But its driving my compiler nuts:
Code:
Error E2294 C:\MOPEngine.h 109: Structure required on left side of . or .* in function IsArrowDown()
Error E2294 C:\MOPEngine.h 111: Structure required on left side of . or .* in function IsArrowDown()
Error E2294 C:\MOPEngine.h 113: Structure required on left side of . or .* in function IsArrowDown()
Error E2294 C:\MOPEngine.h 115: Structure required on left side of . or .* in function IsArrowDown()
Error E2294 C:\MOPEngine.h 117: Structure required on left side of . or .* in function IsArrowDown()
Error E2034 C:\MOPEngine.h 119: Cannot convert 'Keeper (*)()' to 'Keeper' in function IsArrowDown()
Error E2034 C:\MOPEngine.h 363: Cannot convert 'int' to 'Keeper' in function Check(Keeper)
Error E2034 C:\MOPEngine.h 368: Cannot convert 'int' to 'Keeper' in function Check(Keeper)
Error E2034 C:\MOPEngine.h 371: Cannot convert 'int' to 'Keeper' in function Check(Keeper)
*** 9 errors in Compile ***
IsArrowDown code:
Code:
Keeper IsArrowDown() {
Keeper Zouth();
if(GetAsyncKeyState(VK_UP)&SHRT_MAX)
Zouth.Check(0);
if(GetAsyncKeyState(VK_DOWN)&SHRT_MAX)
Zouth.Check(1);
if(GetAsyncKeyState(VK_LEFT)&SHRT_MAX)
Zouth.Check(2);
if(GetAsyncKeyState(VK_RIGHT)&SHRT_MAX)
Zouth.Check(3);
if(GetAsyncKeyState(VK_ESCAPE)&SHRT_MAX)
Zouth.Check(4);
return Zouth;
}
Check code:
Code:
Keeper Check(Keeper x) {
if(x.IsChecked(1)==1) {
MoveRight();
return 1;
}
if(x.IsChecked(2)==1) {
MoveLeft();
return 2;
}
return 0;
}
It seems to not enjoy the use of my class... But I dont see why its rejecting it? I can post my whole source, but its pritty long and I'd rather avoid it.
Thank you!