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
Solved

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

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

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

792 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