User Profile

Collapse

Profile Sidebar

Collapse
herbu
herbu
Last Activity: Apr 19 '10, 05:15 AM
Joined: Apr 8 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Thanks again, akdemirc,

    Now I am clearer at the newly defined class. I slightly revise the codes
    on Vector.h. It would be very much apprepciated in case I could learn your opinions on the revised codes.

    Vector.h (ps: When need to activate the function of checking index of array/matrix boundary, we need to define the flag CHECK_VECTOR_IN DEX.)
    Code:
    #include <iostream>
    #include <stdio.h>
    ...
    See more | Go to post

    Leave a comment:


  • Thanks Akdemirc,

    Yes, it is my fault to forget "#define CHECK_VECTOR_IN DEX" such that the operator overloading in "Vector" is not activated. After defining CHECK_VECTOR_IN DEX, "tmp[0][-1] = 1.00" would be checked.

    However, do you know the meaning of "const T &operator[] (int) const;"
    I learned this from a slides which said it is used to check the boundary when the...
    See more | Go to post

    Leave a comment:


  • Thanks akdemirc,

    However, with this, when declare
    Matrix<double> tmp;
    tmp.assignName( "tmp", 3, 4, 0.00);

    When trying to
    "tmp[-1][0] = 1.00;" we could see the error message due to operator loading
    "template <class T>
    Vector<T> &Matrix<T>::ope rator[] (int idx) "

    However, it could not check "tmp[0][-1] =...
    See more | Go to post

    Leave a comment:


  • Many thanks Akdemirc,

    But in this way, I could not use the object of "Matrix" just like a regular 2-dimensional array. For example, to access the matrix as

    Matrix tmp;
    tmp.assignName( "tmp", 3, 4, 0.00);

    for(int rowIdx = 0;rowIdx < 3;rowIdx++) {
    for(int colIdx = 0;colIdx < 4;colIdx++) {
    tmp[rowIdx][colIdx] = input[rowIdx][colIdx];
    ...
    See more | Go to post

    Leave a comment:


  • How to define a new class "Matrix" based on "Vector<Vector<T>>"?

    In order to automatically check if the index of an array declared by vector<T> exceeding its boundary, we define the class "Vector" derived from "vector" and do the operator overloading as shown in Vector.h. And it works well.
    However, when we need to use the 2-dimensional array, we need to write more than 5 lines in order to initialize the 2-D array, as shown in main.cpp.

    My question is: is there any...
    See more | Go to post
No activity results to display
Show More
Working...