Solved

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

Posted on 2011-03-20
2
708 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
ID: 35176768
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
ID: 35176920
Thanks a lot!
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

776 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