c++ - What is Error C2039 and what does it mean in this case? -


i cannot compile code due errors these:

error c2039: 'difference_type' : not member of 'player' c:\program files (x86)\   microsoft visual studio 12.0\vc\include\xutility 373 1 football simulator" error c2039: 'iterator_category' : not member of 'player'  c:\program files (x86)\   microsoft visual studio 12.0\vc\include\xutility 371 1 football simulator" 

and on.

these messages offer nothing of value on how fix code or compiler having trouble , left code cannot compile. there 1 specific problem code, , getting barrage of useless compiler errors , amidst 1 of useful error tells me actual mistake is

https://www.dropbox.com/s/jr2lmqwvfurpnok/football%20simulator.rar?dl=0 gather of code. reference, lines 371 of xutility read

// template class iterator_traits template<class _iter>     struct iterator_traits     {   // traits iterator _iter     typedef typename _iter::iterator_category iterator_category;     typedef typename _iter::value_type value_type;     typedef typename _iter::difference_type difference_type;     typedef difference_type distance_type;  // retained     typedef typename _iter::pointer pointer;     typedef typename _iter::reference reference;     }; 

this stdafx.h

#pragma once  #include "targetver.h"  #include <stdio.h> #include <tchar.h> #include <iostream> #include <algorithm> #include <cassert> #include <string> #include <time.h> 

and player.h fine.

 #pragma once #include "playerattributes.h" enum position{     gk,     fb,     cb,     dm,     cm,     fw,     max_positions };   class player {     playerattributes attributes;     std::string m_sname;     int m_nage;     position m_eposition;     std::string e_steamname;  public:      player();     player(int ndesiredattributevalues);     //     player(std::string sname, int nage, position eposition);      player(std::string sname, int nage, position eposition, int ndesiredattributevalues);     ~player();      friend std::ostream& operator<< (std::ostream &out, player &cplayer); }; 

edit: , pointed below, actual error lies in file team.cpp

team::team(int nnumberofplayers, int nattributevalue){      acplayer = new player[nnumberofplayers];     std::fill(acplayer[0], acplayer[nnumberofplayers-1], nattributevalue);  // error     nteamsize = nnumberofplayers; } 

nothing useful appeared on error list , in output, 5th message stated:

1> team.cpp(13) : see reference function template instantiation 'void std::fill(_fwdit,_fwdit,const _ty &)' being compiled

how supposed identify problem this? previous method check first error , go line stated, didn't work time.

thanks.

as comment stated above, error show in visual studio output window, didn't see (for reason).

the error states this:

1>  team.cpp(13) : see reference function template instantiation 'void std::fill<player,int>(_fwdit,_fwdit,const _ty &)' being compiled 

that error points in team.cpp file:

//test slow version team::team(int nnumberofplayers, int nattributevalue){      acplayer = new player[nnumberofplayers];     std::fill(acplayer[0], acplayer[nnumberofplayers-1], nattributevalue);  // error     nteamsize = nnumberofplayers; } 

now sees it, can tell issue is. std::fill function requires iterators first 2 parameters, provided full blown objects, not iterators.

the fix this:

    std::fill(acplayer, acplayer + nnumberofplayers, nattributevalue);   

a pointer has same traits iterator satisfies conditions std::fill requires. original problem std::fill algorithm applying operator++ iterator, , since passed object has no ++ defined, error emitted.

so contrary claims in post, these not "nonsense compiler errors". error makes perfect sense.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -