944,131 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 5009
  • C++ RSS
Apr 16th, 2007
0

GUI, matrix and vector libraries

Expand Post »
I originally joined this site almost a year ago so i could find out the name of the GUI library that's in most compilers. Didn't get much help back then.

But I hope that will change. I'm making a sudoku game in C++, so obviously I need a matrix (or a vector of vectors, if possible). Also, I could make it text-based, but I'd rather have some graphics. So, I need a matrix library, and a GUI library.

I thought that vectors were:
C++ Syntax (Toggle Plain Text)
  1. #include <vector.h>
  2. ...
  3. vector<allocator_type> name(length);
But apparently not. And I thought that matrices were:
C++ Syntax (Toggle Plain Text)
  1. #include <matrix.h>
  2. ...
  3. matrix<allocator_type> name(xDim,yDim);
But apparently my compiler doesn't even have the matrix library.

So could somebody help me out? In a nutshell, I'm having trouble with GUI, matrices, and vectors.

(By the way, I'm using Dev-C++ 5 on Windows XP.)
Last edited by the_glitch; Apr 16th, 2007 at 9:51 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
the_glitch is offline Offline
1 posts
since Jul 2006
Apr 16th, 2007
0

Re: GUI, matrix and vector libraries

Not clear whether you have problems in declaring a 2D container or in showing a 2D container's data on a GUI?
If it's already been a year since you started on C++ I'm sure you know that a XxY matrix can be represented by:
c++ Syntax (Toggle Plain Text)
  1. typedef vector<int> ROW_VEC ;
  2. vector< ROW_VEC > matrix ;
  3. int init_values[] = { 1,2,3,4,5,6,7,8,9 } ;
  4. ROW_VEC oneRow( init_values, init_values + 8 ) ;
  5. for( int i = 1; i<=9; i++ )
  6. {
  7. random_shuffle( oneRow.begin(), oneRow.end() ) ;
  8. matrix.push_back( oneRow ) ;
  9. }
  10.  
  11. for( i = 0; i<matrix.size(); i++ )
  12. {
  13. for( int j = 0; j<matrix[i].size(); j++ )
  14. cout << matrix[i][j] << '\t' ;
  15. cout << endl ;
  16. }

For pure C graphics use graphics.h.
For VC++ graphics you can use MS Flexi Grid (I donno what's DevC++)
Last edited by thekashyap; Apr 16th, 2007 at 10:48 am.
Reputation Points: 254
Solved Threads: 74
Practically a Posting Shark
thekashyap is offline Offline
804 posts
since Feb 2007
Apr 16th, 2007
0

Re: GUI, matrix and vector libraries

>I'm making a sudoku game in C++, so obviously I need a matrix (or a vector of vectors, if possible).

...yes a 2d array or variants of.

>Also, I could make it text-based, but I'd rather have some graphics.

If this is your first program then stick to text-based, GUI programming is slightly more involved.

> I thought that matrices were:
#include <matrix.h>

matrices, there is no such thing unless you are talking of the mathematical sense. You probably mean a 2d array.

>So could somebody help me out? In a nutshell, I'm having trouble with GUI, matrices, and vectors.

Yes start with a text based program, and work out your ideas on paper first.

>(By the way, I'm using Dev-C++ 5 on Windows XP.)
Dev has all the features necessary to make a win32 GUI application, but it is considered hard to pick up. For a more user friendly introduction into GUI programming your might want to check out c# or vb.net. But then you got to know OOP, so it is give and take.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Arrays
Next Thread in C++ Forum Timeline: Templates in C++





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC