CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2009
    Posts
    2

    Question what is that I have to define to use += or *=?

    std::map<unsigned int,std::vector<std::vector<double> > > normal;
    std::map<unsigned int, std::vector<std::vector<double> > >::iterator it_Set;

    for(it_Set = mSetContactNormals.begin(); it_Set != mSetContactNormals.end(); ++it_Set)
    {
    std::vector<std::vector<double> > vectorSet(it_Set->second);
    std::vector<std::vector<double> >::iterator it_vs;
    Vector<double> ac_normal(3,0.00);

    for(it_vs = vectorSet.begin(); it_vs != vectorSet.end(); ++it_vs)
    {
    Vector<double> normal_in_set(*it_vs);
    ac_normal += normal_in_set; // error here

    }

    ac_normal *= (1.00/sqrt(std::inner_product(ac_normal.begin(),ac_normal.end(),ac_normal.begin(),0.00))); //errors 1,2

    mContactNormals[it_Set->first] = ac_normal; //3
    }

    1-error C2784: 'class std::complex<_Ty> &__cdecl std:perator *=(class std::complex<_Ty> &,const class std::complex<_U> &)' : could not deduce template argument for 'cl
    *** std::complex<_Ty> &' from 'class std::vector<double,class std::allocator<double> >'

    2-error C2676: binary '*=' : 'class std::vector<double,class std::allocator<double> >' does not define this operator or a conversion to a type acceptable to the predefin
    ed operator

    3-error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'double' (or there is no acceptable conversion)

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: what is that I have to define to use += or *=?

    Please post your code in [code][/code] forum bbcode tags.

    Quote Originally Posted by jhendrix
    what is that I have to define to use += or *=?
    You would need to overload operator+= and operator*= respectively.

    What is a Vector<double>? It looks like it should be some class defined by you, but the error messages hint that it is a std::vector<double> instead. You might want to post the smallest and simplest program that demonstrates the errors.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Join Date
    Jan 2009
    Posts
    6

    Re: what is that I have to define to use += or *=?

    Yes, without code tags, the post is always UNCLEAR, it is advisable to always c.learify code snips with code tags to release eyes strain and more

    All the best

    -Kim Tu

  4. #4
    Join Date
    Jan 2009
    Posts
    2

    Re: what is that I have to define to use += or *=?

    Thanks to both of you, I've solved first two errors but the third is still appearing,

    mContactNormals[it_Set->first] = ac_normal;
    error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'double'
    thanks

  5. #5
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: what is that I have to define to use += or *=?

    Exactly as the error says. mContactNormals[it_Set->first] is not of the same type as ac_normal.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured