Solved

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

Posted on 2011-03-20
2
711 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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 how to use strings and some functions related to them in the C programming language.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

730 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