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

    Why do I get this error?

    class CVRUtilitiesApp : public CWinApp
    {
    public:


    void CopySessions( const CString & src, const CString &dst,const CString & srcLesson, const CString & dstLesson, const vector<Session> &sessionToCopy);
    void CopyLessons( const CString & src, const CString &dst, const vector<Lesson> &lessonToCopy);
    void ToCopySession( const CString & src, const CString &dst, const CString & srcLesson, const CString & dstLesson, const vector<Session> &sessionToCopy);
    void ToCopyLesson( const CString & src, const CString &dst, const vector<Lesson> &lessonToCopy);

    bool GetLessonByName(CString &lessonName,const Lesson &lesson);
    CVRUtilitiesApp();



    void CVRUtilitiesApp::CopySessions( const CString & src, const CString &dst, const CString & srcLesson, const CString & dstLesson, const vector<Session> &sessionToCopy)
    {
    set<CString> tempLesson;
    for( int j= 0; j < sessionToCopy.size(); j++) {
    Directory destRepDir= sessionToCopy[j].GetPath().CalcMvPath((ToString(src)),(ToString(dst)));
    CString lessonName = sessionToCopy[j].GetLessonName();
    if(tempLesson.find(lessonName) == tempLesson.end()){
    tempLesson.insert(lessonName);
    Lesson l;
    if(GetLessonByName(lessonName, l))
    CopyLessons(srcLesson, dstLesson, l);

    }

    }
    }
    bool CVRUtilitiesApp::GetLessonByName(CString &lessonName, const Lesson &l)
    {

    for (int i=0; i< lessonRawList.size(); i++) {
    if(lessonRawList[i].GetLessonName() = lessonName)
    l = lessonRawList[i];
    return true;
    }

    }

    :\projet2\VRUtilities\VRUtilities.cpp(742) : error C2664: 'CopyLessons' : cannot convert parameter 3 from 'class Lesson' to 'const class std::vector<class Lesson,class std::allocator<class Lesson> > &'
    Reason: cannot convert from 'class Lesson' to 'const class std::vector<class Lesson,class std::allocator<class Lesson> >'
    No constructor could take the source type, or constructor overload resolution was ambiguous
    K:\projet2\VRUtilities\VRUtilities.cpp(758) : error C2678: binary '=' : no operator defined which takes a left-hand operand of type 'const class Lesson' (or there is no acceptable conversion)



  2. #2
    Guest

    Re: Why do I get this error?

    The first error message is caused by the call to CopyLessons. It expects the 3rd argument to be a vector of Lessons, and you are passing only a single Lesson. To call it as it stands you need to create a temporary vector<Lesson>, add your Lesson to it, and then pass the vector.

    The other message is caused by the opposite problem. I can't see the declaration of lessonRawList, but since you have a loop from i=0 to lessonRawList.size(), I assume lessonRawList is a vector of Lessons. However GetLessonByName returns only a single Lesson. Within your loop over i, use lessonRawList [ i ] to refer to the current lesson.


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