User Profile

Collapse

Profile Sidebar

Collapse
Stefano112
Stefano112
Last Activity: Feb 22 '10, 04:03 PM
Joined: Jan 29 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Stefano112
    replied to How to make an iterator for my Matrix class
    in C
    thanks again for your patience, now i'm trying to do it like you suggested...
    i've declared data like a pointer to my value type (valuet *data), then in constructor when i do:
    data = new valuet[row][col];
    i get this error:
    error: 'col' cannot appear in a constant-expression

    it doesn't allow me to create a bidimensional array but just a normal array...
    See more | Go to post

    Leave a comment:


  • Stefano112
    replied to How to make an iterator for my Matrix class
    in C
    well but as also Banfa said the data in my matrix are not contiguos, so if i have
    1 2 3
    4 5 6
    7 8 9
    element 5 will not be the address of element 0 + 4 x sizeof(the element)...if i add sizeof(element) to element 3, i will get a value that is not in the first row, and is not in the second row, it's just between the two rows!
    So as Banfa said i have to make my operator++ of the iterator more complicated, i've done...
    See more | Go to post

    Leave a comment:


  • Stefano112
    replied to How to make an iterator for my Matrix class
    in C
    but my array is bidimensional (**_data), so when i have:
    1 2 3
    4 5 6
    7 8 9

    there are same values between the rows (like a 0 and a 33...but i think they can change :P)
    so how can i move from a row to an another without incrementing both *ptr and ptr?
    thanks for your answer weaknessforcats , i have to finish this project in a few days but i can't fix this last problem :/ i hope someone can help me!
    See more | Go to post

    Leave a comment:


  • Stefano112
    replied to How to make an iterator for my Matrix class
    in C
    WARNING:i know it's a long post (cause there is a lot of code), but i m asking just for a little problem, please try to help me even if it's long cause i really need your help!

    ok now i fixed the main problem, now when i try to read or to set all the elements of the matrix it works, but i have another little problem, first of all, here is my class iterator (nested inside class matrice (matrix in italian :P), and the two functions...
    See more | Go to post

    Leave a comment:


  • Stefano112
    replied to How to make an iterator for my Matrix class
    in C
    thanks a lot for your answer, unfortunately i cannot use the second option cause the teacher asked us to not implement the matrix in that way
    I have already tried the first option, but i wasn't able to make it works...cause i would need to compare my pointer with _data[row][_col-1], then if they are the same skip to _data[row+1][0], else i would just increment my pointer
    The problem is that i dont understand how can i make _data of...
    See more | Go to post

    Leave a comment:


  • Stefano112
    started a topic How to make an iterator for my Matrix class
    in C

    How to make an iterator for my Matrix class

    Hi, i'm making a matrix class, here is my code:

    Code:
    #ifndef MATRICE_H
    #define MATRICE_H
    
    #include <iostream>
    
    template <class T> class matrice {
    
     public:
      
      typedef int sizet;
      typedef T valuet;
      
     matrice(): _data(0), _row(0), _col(0) {}; //costruttore default
      
      matrice(sizet rw, sizet cl) { //causa errore in valgrind
    ...
    See more | Go to post
No activity results to display
Show More
Working...