User Profile

Collapse

Profile Sidebar

Collapse
Guille
Guille
Last Activity: Nov 10 '08, 09:53 AM
Joined: Nov 5 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Guille
    replied to Operator overloading and parenthesis
    in C
    No, Ganon11, that code didn't work with matrixes of different sizes :) I've fixed that, thanks....
    See more | Go to post

    Leave a comment:


  • Guille
    replied to Operator overloading and parenthesis
    in C
    It finally seems to work, but it looks so easy now. I don't know why I messed up with references and so. Do you see any problem to the following code?

    Code:
    class Matrix {
    private:
    	double *data;
    
    public:
    	int nRow, nCol;
    	Matrix (int, int);			   
    	Matrix (int, int, string);
    	double& operator() (int, int);
    	Matrix operator+ (Matrix);	   
    	Matrix operator* (Matrix);
    ...
    See more | Go to post

    Leave a comment:


  • Guille
    replied to Operator overloading and parenthesis
    in C
    Focusing in these two lines:

    Code:
    matrix& matrix::operator*=(matrix& rhs) {...}
    ...
    {
        matrix tmp= matrix(*this);
    What's calling the function (overloaded operator) defined in the first line, *this or matrix(*this)?

    If it's not matrix(*this), what's matrix(*this) supposed to be? A constructor who copies the result obtained from *this into the newly created matrix?...
    See more | Go to post

    Leave a comment:


  • Guille
    replied to Operator overloading and parenthesis
    in C
    Ganon11 and JosAH:

    Sorry, but I don't really catch it. I should overload the "*this", and that's done with somethig like this?

    matrix matrix::operato r*=( ??? )

    What should the parameter be? What should it return. Itself? With "return *this"?


    Boxfish:

    I had already tried to return temp itself. It works, and right, the array will remain, as the memory...
    See more | Go to post

    Leave a comment:


  • Guille
    replied to Operator overloading and parenthesis
    in C
    Hi JosAH,

    Thanks for your reply, but I can't fully understand what do you mean. Could you express it in another way, or sketch it with some code?

    Just in case it wasn't clear (I don't know if you suggest this), I DON'T want to modify the original matrix. I want the function to give back a new one, without modifying the old one.

    Thanks once again,

    Guille...
    See more | Go to post

    Leave a comment:


  • Guille
    started a topic Operator overloading and parenthesis
    in C

    Operator overloading and parenthesis

    Hi there,

    I'm a new user of this forum and quite of a newbei in C/C++. I'd appreciate it if you could help me with one problem I'm having at the moment.

    I've prepared a class to deal with matrices (yes, there are many of them around, but I found it a good exercise to learn all this staff). I've defined some methods with a * and + overloaded operators.

    For example:

    Code:
    Matrix& Matrix::operator*
    ...
    See more | Go to post
No activity results to display
Show More
Working...