Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-03-20
2
Medium Priority
?
771 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
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…

610 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