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

GUI, matrix and vector libraries

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:

#include <vector.h>
...
vector<allocator_type> name(length);


But apparently not. And Ithought that matrices were:

#include <matrix.h>
...
matrix<allocator_type> name(xDim,yDim);


But apparently my compiler doesn't evenhave 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.)

the_glitch
Newbie Poster
1 post since Jul 2006
Reputation Points: 10
Solved Threads: 0
 

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:

typedef vector<int> ROW_VEC ;
    vector< ROW_VEC > matrix ;
    int init_values[] = { 1,2,3,4,5,6,7,8,9 } ;
    ROW_VEC oneRow( init_values, init_values + 8 ) ;
    for( int i = 1; i<=9; i++ )
    {
        random_shuffle( oneRow.begin(), oneRow.end() ) ;
        matrix.push_back( oneRow ) ;
    }

    for( i = 0; i<matrix.size(); i++ )
    {
        for( int j = 0; j<matrix[i].size(); j++ )
            cout << matrix[i][j] << '\t' ;
        cout << endl ;
    }


For pure C graphics use graphics.h.
For VC++ graphics you can use MS Flexi Grid (I donno what's DevC++)

thekashyap
Practically a Posting Shark
811 posts since Feb 2007
Reputation Points: 254
Solved Threads: 75
 

>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

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.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You