0

I'm new to CPP, can't find a simple documentation on how to declare a private constant class attribute, and if it should go on the .h or .m

Here's what I have on my Horse.h:

class Horse {
 private:
 static const int body_vertex_quantity = 24;
 float left_ear_vertex_array[ears_vertex_quantity][2] = {
 //
 };
 public:
 draw();
}

But I'm getting

cannot specify explicit initializer of arrays

I have made my research in the following links, but I don't understand the syntax or what they're doing since I'm new to cpp

Initializing a member array in constructor initializer

Error: cannot specify explicit initializer for array

Workaround for error C2536: cannot specify explicit initializer for arrays in Visual Studio 2013

cannot specify explicit initializer for arrays

asked Sep 4, 2014 at 20:57
5
  • 4
    The second member isn't static. Commented Sep 4, 2014 at 20:59
  • 1
    .h or .m? Aren't .m files for Objective-C, not C++? And if you wanted Objective-C++, that's a .mm file, right? Commented Sep 4, 2014 at 21:02
  • Do this left_ear_vertex_array { // } in the member initializer list of a constructor function, not in the declaration! Commented Sep 4, 2014 at 21:13
  • variables cannot be used to declare array size. Instead make it float left_ear_vertex_array[24][2] Commented Sep 4, 2014 at 21:15
  • If possible, use C++11 and its std::array, otherwise use std::vector Commented Sep 4, 2014 at 21:38

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.