I am following along with a video emulating a cpu in C++. The programmer used the following and it is the first time I encounter it:
This is the code from the video:
struct Mem
{
Byte Data[MAX_MEM];
Byte operator[]( u32 Offset ) // <-- I don't understand this syntax
{
}
}
I wrote it in my own project like this:
char data[1024*64];
char fun[] ( int x ) const // <-- Is this right?
{
return data[x];
}
my issue is with line 1#
of the example. They were able to compile but I am met with errors:
incomplete type is not allowed;
array of functions is not allowed;
a type qualifier is not allowed on a nonmember function.
What does this syntax actually do; is there an alternative way to write it?
question from:https://stackoverflow.com/questions/65547111/what-does-char-funint-x-const-do-c-syntax-error