954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Initializing an array as a class mamber

I have found out through the compiler that you cannot declare and initialize an array within a class header file. I was trying to figure out how I might go about getting a 5 by 14 array initialized as a private mamber within the class. I have included the header file and the class cpp file, neither are in full working form, but you should be able to get the idea about what i am trying to accomplish. thanks for taking a look.

Attachments vend.h (1.29KB) vend.cpp (3.69KB)
rporter1
Newbie Poster
1 post since Dec 2004
Reputation Points: 10
Solved Threads: 0
 

you cannot declare and initialize an array in header file.but u can crate as many as u want object of any class member in your .c++ file so using this u can create run time array. think on this

achyut
Newbie Poster
11 posts since Feb 2005
Reputation Points: 10
Solved Threads: 0
 

All you have to do is move or more specifically code appropriately in Vend::Vend (default constructor) the values you want in fasm. This is how variables are initialized in a class, like int value [1][2] = {4, 8}; would be too code.

Tight_Coder_Ex
Posting Whiz in Training
215 posts since Feb 2005
Reputation Points: 47
Solved Threads: 17
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You