I wrote a game using an array of structs to represent a 9x9 grid. Now I'm re-writing it as a class to '++ it up' a bit and to better understand classes. Part of the game used a seperate struct to keep track of selected board squares (to see if they match). Would it be proper ettiquete to include a struct as a class member, or is there a more 'proper' way?
jkhippie 0 Newbie Poster
Recommended Answers
Jump to PostIn c++ stucts can even have methods just like class. The only method I use in a struct is a constructor to initialize all the data. If you add other methods then you'd be better off just renaming the struct as class.
Jump to Postyou have the word const in the wrong place
void Draw() const
See this tutorial
All 8 Replies
vmanes 1,165 Posting Virtuoso
jkhippie 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
jkhippie 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
jkhippie 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
jkhippie 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.