Hello xeuz,
You have a good start.
Using an enum class these lines:
1 2
|
struct Pixel b = { Colors BLACK }
struct Pixel w = { Colors WHITE }
|
Should be written as:
1 2
|
struct Pixel b = { Colors::BLACK }
struct Pixel w = { Colors::WHITE }
|
See
http://www.cplusplus.com/doc/tutorial/other_data_types/#enum_class
Line 22 should be inside "main". It is best to avoid using global variables like this.
An array like this will work, but a
std::vector<Pixel> pixel;
is a better choice.
"main" should contain the code to call the functions and direct the program flow.
Line 16
const int Width, Height = 0;
. Both variables, as with all regular variables, should start with a lower case letter. Upper case letters are used for "class"es and "struct"s. "width" has no value assigned and "height" is set to zero. Both being defined as a "const" these values can never be changed. The for loop should be giving you an error because you are trying to change a variable that can not be changed. I believe what you want here is:
int width{}, height{};
. The empty {}s will initialize the variables to zero or you could put a number inside the {}s.
Unless you have a need for "width" outside of the for loop it is better to write the for loop as:
for (int width = 0; width < 10; width++)
. And be careful you started with
"Width", but ended with
"width++. The difference between the capital and lower case "W" is a completely different variable.
I did not catch this at first, but line 11 ends with a semi-colon which ends the "struct". The next two lines being indented gave the impression that they should belong to the "struct", but they do not.
I think what you meant is:
1 2 3 4 5
|
struct Pixel
{
struct Pixel b = { Color::BLACK }
struct Pixel w = { Colors::WHITE }
};
|
With the {}s the "=" is not needed.
Line 15 is a nice prototype. Lines 16 and 17 just because they are indented does not make them part of the function. The semi-colon at the end of line 15 makes it a prototype not a function. Again I think what you meant is:
1 2 3 4 5 6 7 8 9 10
|
void CreateShape(Pixel p[], int nPixels, Shapes Shape)
{
int width, weight = 0;
for (int width = 0; width < 10; width++) // <--- better way to write for loop.
{
// <--- needs some code here.
} // End for loop.
} // End function.
|
The {}s in column 1 make it a function. The for loop needs to do something inside the {}s. And line 3 is not really needed.
And you have the same problem with lines 18 and 20.
As I said you have a good start, but need to fix the problems and add something to "main" to make use of all this.
Hope that helps,
Andy