problems with pointers and internal representation.


 
Thread Tools Search this Thread
Top Forums Programming problems with pointers and internal representation.
# 1  
Old 05-25-2011
problems with pointers and internal representation.

I am trying to implement the representation in the attached file.
Code:
class matriz {
      private:
              int fil,col;
              int **filaspointer; 
              int *buffer;       
              
      public:
             matriz();
             matriz(int fil,int col);
             };

matriz::matriz(int fil,int col) {
 fil=fil;
 col=col;
 *filaspointer=new int[fil];
 for (int i=0; i<fil; i++){
     buffer=new int[col];
     filaspointer[i]=buffer;
 }
}


int main () {
    matriz test(2,3);

The program just closes when I execute it (i am 100 % sure its because the pointers are pointing the wrong direction Smilie)
But uh...I cannot see the problem here (maybe it lies down within the representation?).
problems with pointers and internal representation.-implpng
# 2  
Old 05-25-2011
Well, you are assigning to a dereferenced pointer, but nobody put a pointer in there to dereference, so SEGV; lose the asterisk:
Code:
filaspointer=new int[fil];

# 3  
Old 05-25-2011
That won't even compile, it gives me this error in that exact line:

In constructor `matriz::matriz(int, int)':
cannot convert `int*' to `int**' in assignment
# 4  
Old 05-25-2011
Well, to match, you need to lose the * in the definition, too.

Dynamic Memory - C++ Documentation

However, now I see from your diagram, you want a new array of pointers to a two dimensional array! Can the loop!
Code:
filaspointer=new int[fil][col];

This User Gave Thanks to DGPickett For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Programming

How bit representation of a number can be done in c?

I have an assignment in which a character is the input of which some bits(from a position to certain position) are to be inverted (1's complement) and then the resultant character is to be returned....for example unsigned char x = J from p = 3 to offset n = 5 01001010 inverted to... (1 Reply)
Discussion started by: ezee
1 Replies

2. Shell Programming and Scripting

Convert a matrix to sparse representation

Hi All, I have a matrix stored in a file matrix.mtx and looks like this: 1 0.5 0.33 0.25 0 0.33 0.25 0.2 0 0 0 0.16 0 0 0 0.14 I want to convert this matrix to its sparse representation like the one give below (sparse_matrix.mtx). This means that above matrix has been converted to its... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

3. Programming

Internal representation of double

I came across a puzzle which I can not explain. The setup is SCO OpenServer 5.7 (32 bit OS) and native SCO compiler. double is 8 bytes long on this system. I am able to populate the double variable with two different sets of values that produces the same double value, please see below: #include... (7 Replies)
Discussion started by: migurus
7 Replies

4. Shell Programming and Scripting

Question on file owner name representation

Hi All, I came across a situation where i saw a directory name given below: drwxrwxrwx 5 121973 staff 8192 Apr 26 23:47 arunpr Just for your info: 1. All our application user ids are LDAP. 2. Hence we will not see any details of user in /etc/passwd file and i believe this could... (6 Replies)
Discussion started by: Arunprasad
6 Replies

5. UNIX for Advanced & Expert Users

Forwarding internal internet packets to internal webserver using iptables

Hi, I need to redirect internal internet requests to a auth client site siting on the gateway. Currently users that are authenticated to access the internet have there mac address listed in the FORWARD chain. All other users need to be redirected to a internal site for authentication. Can... (1 Reply)
Discussion started by: mshindo
1 Replies

6. Infrastructure Monitoring

visual representation of server health

HI all, I want to make a webpage showing the status of services running on a server. for example email, http , etc. That way users can see that server status for themselfs. Maybe even show the status of each virtual domain running on the server. Any way to do this without buying some product? ... (4 Replies)
Discussion started by: mcraul
4 Replies

7. Solaris

Disk Representation - what is this c1t1d0s2 represent?

Hi All, Can you please advise what the 't' letters stands for? I understand the letter for the following "c1t1d0s2": c = disk Controller t = ? d = disk number ID. s = slice or partition of the disk Thanks (2 Replies)
Discussion started by: tlee
2 Replies

8. Linux

Problems with the Internal modem

Hi I have a hsf Conexant modem & I have a driver for it but it works only on 2.4.* kernels . I know that there is a site called Linuxant.com which offers kernels for download ,but it gives a speed near 14 kb/s and the full feature driver offered for money and I can't buy it. My questions... (3 Replies)
Discussion started by: engshaheen
3 Replies
Login or Register to Ask a Question