Society of Robots - Robot Forum
Software => Software => Topic started by: jamort on June 27, 2009, 06:22:48 PM
-
ive never really used classes and im trying to make a chess game and i keep having a problem because I think its the type of information im trying to store or something... I'm trying to get this straight so i can get on with my program.... heres what im trying to do i know its wrong please help..
#include<iostream>
namespace chess {
class chess_board{
int *chess_board[8][8];
};
}
-
I believe the problem is how you are naming your array. I don't think arrays in C can start with *
-
I believe the problem is how you are naming your array. I don't think arrays in C can start with *
He's declaring a 2D array of pointers to integers, that ok. I don't see anything wrong with this code. I actually compiled it and g++ didn't complain.
Could you give us more details? like the error message you're getting.
By the way, classes don't exist in C.
Chelmi.
-
#include<iostream>
namespace chess {
class chess_board{
int *chess_board[8][8];
};
}
errors:
[Linker error] undefined reference to `WinMain@16'
ld returned 1 exit status
im using dev c++ 4.9.9.2... Im not sure what im doing wrong but as I said I've never really used classes...
edit... this is weird i add this and the code works...
#include<iostream>
namespace chess {
class chess_board{
int *chess_board[8][8];
};
}
using namespace std;
int main(){
cout<< "Hello there";
cin.get();
}
-
Your problem is not the class. The compiler is complaining because you don't have a main fuction (called WinMain in windows I guess).
Your fix is not weird at all ;)
-
but i swear ive seen programs without functions before ??? idk though problem solved
-
Unless you are writing a library, every program needs a main function. But it can be in a different file.
-
oh yeah the pointers I forgot about the pointers thanks for reminding me. I don't have that much C++ experience, just what I needed to know to get through my data structures class ;)
-
you ever applied classes to your robots?