Solved

How to convert function from visual studio C++ to QT c++ ?

Posted on 2011-03-20
2
706 Views
Last Modified: 2012-05-11
Hi Experts,

I have this function:
Vector Vector::operator *(Matrix &m)      // return MatrixMulVector(this, m)
{    
    return (m * (*this));
}

where Vector:

        Vector()                        { Set(0, 0, 0); }
      Vector(float _x, float _y, float _z)      { Set(_x, _y, _z); }
        Vector(Vector &v)                  { Set(v.x, v.y, v.z); }

and Matrix:

Matrix()                                                { memset(p,0,sizeof(float)*9); }                              // nullify matrix
      Matrix(      float xx, float xy, float xz,
                  float yx, float yy, float yz,
                  float zx, float zy, float zz)      { Set(xx, xy, xz,  yx, yy, yz,  zx, zy, zz); }            // construct matrix from 9 floats
        Matrix(float ax, float ay, float az)      { SetAng(ax, ay, az); }                                          // construct matrix form 3 angles
      Matrix(Matrix &m)                                    { memcpy(p, m.p, sizeof(float)*9); }

My problem is that I can't compile it in QT 4.7 for Linux. However, it works without any problem in Visual Studio.

In QT I get this error:

no matching function for call to 'Vector::Vector(Vector)'
candidates are: Vector::Vector(Vector&)

Can someone tell me what should I change to create the equivalent of this function in QT ?

Thanks,
Peter



0
Comment
Question by:PeterVarain
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
Comment Utility
Try to change the vector's copy constructor to

        Vector(const Vector &v)  { Set(v.x, v.y, v.z); }  // notice 'const'
0
 

Author Closing Comment

by:PeterVarain
Comment Utility
Thanks a lot!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now