Armenian Knowledge Base  

Go Back   Armenian Knowledge Base > Technical sections > Languages, Compilers, Interpreters
Register

Reply
 
LinkBack Thread Tools
Old 25.07.2002, 09:08   #1
Студент
 
Join Date: 03 2002
Location: [ Surrealistical World ]
Posts: 312
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post Matrixes n Functions

How do we pass a matrix as an argument to a function WITHOUT USING POINTERS??

Thx
Reply With Quote
Old 25.07.2002, 12:38   #2
Студент
 
Join Date: 06 2002
Location: Yerevan
Posts: 258
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

What do you mean by "matrix"? I mean what c++ construction?

And what's the reason you don't wanna use pointers (or arrays, which are basically the same)??

Just final note, whatever you use (unless you assign a separate variable to each element), it will contain pointers in some form.
__________________
http://www.d-brane.com
Reply With Quote
Old 26.07.2002, 08:03   #3
Студент
 
Join Date: 03 2002
Location: [ Surrealistical World ]
Posts: 312
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

Matrix = 2D [two-dimensional] array.

|g0t n0 time t0 write m0re]
Reply With Quote
Old 26.07.2002, 09:03   #4
Студент
 
Join Date: 06 2002
Location: Yerevan
Posts: 258
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

You have to use pointers.
Reply With Quote
Old 26.07.2002, 09:32   #5
Студент
 
Join Date: 03 2002
Location: [ Surrealistical World ]
Posts: 312
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

Read my first message.
Reply With Quote
Old 26.07.2002, 09:37   #6
Студент
 
Join Date: 06 2002
Location: Yerevan
Posts: 258
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

You have to use pointers.
In other words this means - NO way.

All ways I can think of involves pointers in this or other form - pointers, arrays, even functions with indefinite number of arguments, etc.
Reason - to store an array in a program you never store each element in a different variable, you just store the start position, and then just do small steps to get others, or store a link in each element to the other one.

P.S. Maybe I'm not getting your question right, so you should consider rephrasing it, showing the cpp code of the matrix you want to pass and then asking the same question.
Reply With Quote
Old 27.07.2002, 20:08   #7
Младенец
 
Join Date: 07 2002
Location: Yerevan
Posts: 28
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

Create a class that incapsulates 2D matrix functionality and write copy constructor.

But I would not recommend doing it because will work very inefficient(big object copying), the same result can be achieved by using const Matrix& as an argument to the function instead.
Reply With Quote
Sponsored Links
Reply

Thread Tools


На правах рекламы:
реклама

All times are GMT. The time now is 01:25.


Powered by vBulletin® Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.