-6

I wanted to know how can I create new matrixes with different width & height by passing values to class.

for example:

  myClass map1;

  map1.matrix[width][height] = { "###","###"}

( this is not the corrcet code but im looking for something like that )

  • I think you're confused about what a matrix is, and what a map is... I think you should go read a good book https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list – UKMonkey Dec 03 '17 at 15:51
  • I mean the map of the game using matrix ( console game ) ( for example lvl 1 have some walls and a goal and created with 20x20 matrix, like that ) – Display name Dec 03 '17 at 15:52
  • Where is myClass defined? – JLev Dec 03 '17 at 15:55
  • #include #ifndef CONSOLE_H #define CONSOLE_H #pragma once class Console { public: int x = 1; int y = 1; Console(); ~Console(); void Move(int V, int H); }; extern char map[6][16]; extern char map2[6][16]; #endif ( i used something like that but i want to make a map for every levels with only giving its length , width , and map characters by passing them to class from main class ) – Display name Dec 03 '17 at 15:57

1 Answers1

0

Try using Boost.MultiArray. It allows you to create multidimensional arrays with contents of arbitrary content type. I have used it (the boost::multi_array_ref part to be more specific) and it works pretty nice. An important feature is the ability to create array views (and slices based on views).