Thread: Arbitrarily large vector class

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2022
    Posts
    1

    Arbitrarily large vector class

    In my homework they ask for any large vector in 2 dimensions. I need to implement multiplication operation.
    Code:
    #include <iostream>
    #include <vector>
    using namespace std;
    
    class TDVect {
    private:
      unsigned int row;
      unsigned int column;
    
      double TDvect[row][column];
    
    public:
       TDVect(unsigned int A, unsigned int B) {
        row = A;
        column = B;
      } 
      unsigned int getLength() {  //to do: parameterize, return number of row or columns
        return row;
      }
      unsigned int getWidth() {
        return column;
      }
      double getElement(unsigned int i, unsigned int j) {
        return TDVect[i][j];
      }
      void setElement(unsigned int i, unsigned int j, double x) {
        TDVect[i][j] = x;
      }
    };
    
    class V:public TDVect {
      V():TDVect(1, 2) {
    }};
    
    class M:public TDVect {
      M():TDVect(2, 2) {
    }};
    
    V multiplication(V F, M G)
    {                               //to do: row times column
      V vmid();
      vmid.setElement(0, 0, F[0][0] * G[0][0] + F[0][1] * G[1][0]);
      vmid.setElement(0, 1, F[0][0] * G[0][1] + F[0][1] * G[1][1]);
      return vmid;
    }
    
    int main()
    {
      TDVect vectobjA(-1, +9);      //expected error; not given
      cout << vectobjA.getLength() << " ";
      return 0;
    }
    I'm getting quite a few errors in VScode :
    E0245,EO254,E0040,E0028.
    I guess the errors are related to each other but I dont understand them.
    We did't have STD::Vector in the lectures.
    Last edited by Salem; 12-19-2022 at 12:25 PM. Reason: Removed crayola

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 17
    Last Post: 08-05-2018, 06:59 PM
  2. Reading an arbitrarily long line
    By deathslice in forum C Programming
    Replies: 32
    Last Post: 03-23-2016, 09:45 PM
  3. multiply arbitrarily large real numbers
    By Martin0027 in forum C Programming
    Replies: 7
    Last Post: 05-17-2011, 01:59 PM
  4. Making stack class using vector class
    By spank in forum C++ Programming
    Replies: 9
    Last Post: 08-10-2007, 03:50 AM
  5. Help locate an ideal large number class
    By simpleid in forum C++ Programming
    Replies: 2
    Last Post: 08-08-2007, 08:05 AM

Tags for this Thread