0

I have a base class called Matrix which has a function transpose. I also have a derived class Matrix2 which is inherited publicly from Matrix

class Matrix
{
 public:
    Matrix();
    ...
    Matrix Transpose(void);
...
    };

class Matrix2 : public Matrix
    {
     public:
        Matrix2();
        ...
      };

In my main code, I tried this.

vector <Matrix2> myMatrix2;
vector <Matrix> *b = &myMatrix2;

to do this

b->transpose();

But I get the following error

error C2440: 'initializing' : cannot convert from 'std::vector<_Ty> *' to 'std::vector<_Ty> *'

What is wrong...

What is the way to access the transpose function from Matrix class in vector?

I get the following error.

error C2039: 'transpose' : is not a member of 'Matrix2'

Thanks

Edited by mcodesmart

3
Contributors
2
Replies
28
Views
3 Years
Discussion Span
Last Post by pappu.thakare.5
0

b is a pointer to a vector, not to a Matrix2. vector's don't have transpose() method.

myMtrix2[0].transpost() may be what you want. Or if you want to call that method for each Matrix2 in the vector

for(auto x : myMatrix2)
{
   x.transpost();
}

The above requires c++11 compiliant compiler, and iterates through each of the vector's objects.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.