Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. stupid VC++ 7 error...

stupid VC++ 7 error...

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++visual-studiocomgraphics
20 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Christian Graus

    I'm not going to reboot into W2000, run .Net ( which I still don't know my way around ), reboot again, redial the internet, when you can just post the offending line of source yourself. To be honest, if it wasn't that much hassle, I would do it gladly, although I still think you should have posted the source that is crashing, but to test under .Net is simply too much hassle for me. Christian I have come to clean zee pooollll. - Michael Martin Dec 30, 2001

    Sonork ID 100.10002:MeanManOz

    I live in Bob's HungOut now

    M Offline
    M Offline
    Mario M
    wrote on last edited by
    #11

    The error comes from the first line here... ---- vector vecnrDomains; if (!EnumDomains(NULL, vecnrDomains)) return false; for (vector::const_iterator ci = vecnrDomains.begin(); ci != vecnrDomains.end(); ++ci) vecstrDomains.push_back(ci->GetRemoteName()); ------ I am not the author of these sources, someone else posted it to codeguru.com, and it works fine with VC++ 6. - Mario

    C 1 Reply Last reply
    0
    • M Mario M

      The error comes from the first line here... ---- vector vecnrDomains; if (!EnumDomains(NULL, vecnrDomains)) return false; for (vector::const_iterator ci = vecnrDomains.begin(); ci != vecnrDomains.end(); ++ci) vecstrDomains.push_back(ci->GetRemoteName()); ------ I am not the author of these sources, someone else posted it to codeguru.com, and it works fine with VC++ 6. - Mario

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #12

      Mario M. wrote: The error comes from the first line here... ---- vector vecnrDomains; if (!EnumDomains(NULL, vecnrDomains)) return false; for (vector::const_iterator ci = vecnrDomains.begin(); ci != vecnrDomains.end(); ++ci) vecstrDomains.push_back(ci->GetRemoteName()); ------ You mean declaring the vector ? Your <> pairs were lost because you didn't post 'as-is' ( see the check box below as you're typing your post ), but whatever is in the vector: does it have a copy constructor ? Christian I have come to clean zee pooollll. - Michael Martin Dec 30, 2001

      Sonork ID 100.10002:MeanManOz

      I live in Bob's HungOut now

      M 1 Reply Last reply
      0
      • C Christian Graus

        Mario M. wrote: The error comes from the first line here... ---- vector vecnrDomains; if (!EnumDomains(NULL, vecnrDomains)) return false; for (vector::const_iterator ci = vecnrDomains.begin(); ci != vecnrDomains.end(); ++ci) vecstrDomains.push_back(ci->GetRemoteName()); ------ You mean declaring the vector ? Your <> pairs were lost because you didn't post 'as-is' ( see the check box below as you're typing your post ), but whatever is in the vector: does it have a copy constructor ? Christian I have come to clean zee pooollll. - Michael Martin Dec 30, 2001

        Sonork ID 100.10002:MeanManOz

        I live in Bob's HungOut now

        M Offline
        M Offline
        Mario M
        wrote on last edited by
        #13

        I have modified the post to 'as-is'. And here is the vector class... also you can read again the previous message with 'as-is'... class CSelectComputerNetwork { public: CSelectComputerNetwork(); virtual ~CSelectComputerNetwork(); public: static bool GetDomains(vector >& vecstrDomains); static bool GetServers(const basic_string& strDomain, vector >& vecstrServers); private: //NETRESOURCE structure wrapper used to save text data that freed by WNetEnumClose(_); class CNETRESOURCE { public: CNETRESOURCE(const NETRESOURCE& nr): m_nr(nr) { m_strLocalName = nr.lpLocalName ? nr.lpLocalName : _T(""); m_strRemoteName = nr.lpRemoteName ? nr.lpRemoteName : _T(""); m_strComment = nr.lpComment ? nr.lpComment : _T(""); m_strProvider = nr.lpProvider ? nr.lpProvider : _T(""); m_nr.lpLocalName = new TCHAR [m_strLocalName.size() + 1]; _tcscpy(m_nr.lpLocalName, m_strLocalName.c_str()); m_nr.lpRemoteName = new TCHAR [m_strRemoteName.size() + 1]; _tcscpy(m_nr.lpRemoteName, m_strRemoteName.c_str()); m_nr.lpComment = new TCHAR [m_strComment.size() + 1]; _tcscpy(m_nr.lpComment, m_strComment.c_str()); m_nr.lpProvider = new TCHAR [m_strProvider.size() + 1]; _tcscpy(m_nr.lpProvider, m_strProvider.c_str()); } CNETRESOURCE(const CNETRESOURCE& rhs): m_nr(rhs.m_nr), m_strLocalName(rhs.m_strLocalName), m_strRemoteName(rhs.m_strRemoteName), m_strComment(rhs.m_strComment), m_strProvider(rhs.m_strProvider) { m_nr.lpLocalName = new TCHAR [m_strLocalName.size() + 1]; _tcscpy(m_nr.lpLocalName, m_strLocalName.c_str()); m_nr.lpRemoteName = new TCHAR [m_strRemoteName.size() + 1]; _tcscpy(m_nr.lpRemoteName, m_strRemoteName.c_str()); m_nr.lpComment = new TCHAR [m_strComment.size() + 1]; _tcscpy(m_nr.lpComment, m_strComment.c_str()); m_nr.lpProvider = new TCHAR [m_strProvider.size() + 1]; _tcscpy(m_nr.lpProvider, m_strProvider.c_str()); } ~CNETRESOURCE() { delete [] m_nr.lpLocalName; delete [] m_nr.lpRemoteName; delete [] m_nr.lpComment; delete [] m_nr.lpProvider; } public: NETRESOURCE* operator &() {

        C T 2 Replies Last reply
        0
        • M Mario M

          I have modified the post to 'as-is'. And here is the vector class... also you can read again the previous message with 'as-is'... class CSelectComputerNetwork { public: CSelectComputerNetwork(); virtual ~CSelectComputerNetwork(); public: static bool GetDomains(vector >& vecstrDomains); static bool GetServers(const basic_string& strDomain, vector >& vecstrServers); private: //NETRESOURCE structure wrapper used to save text data that freed by WNetEnumClose(_); class CNETRESOURCE { public: CNETRESOURCE(const NETRESOURCE& nr): m_nr(nr) { m_strLocalName = nr.lpLocalName ? nr.lpLocalName : _T(""); m_strRemoteName = nr.lpRemoteName ? nr.lpRemoteName : _T(""); m_strComment = nr.lpComment ? nr.lpComment : _T(""); m_strProvider = nr.lpProvider ? nr.lpProvider : _T(""); m_nr.lpLocalName = new TCHAR [m_strLocalName.size() + 1]; _tcscpy(m_nr.lpLocalName, m_strLocalName.c_str()); m_nr.lpRemoteName = new TCHAR [m_strRemoteName.size() + 1]; _tcscpy(m_nr.lpRemoteName, m_strRemoteName.c_str()); m_nr.lpComment = new TCHAR [m_strComment.size() + 1]; _tcscpy(m_nr.lpComment, m_strComment.c_str()); m_nr.lpProvider = new TCHAR [m_strProvider.size() + 1]; _tcscpy(m_nr.lpProvider, m_strProvider.c_str()); } CNETRESOURCE(const CNETRESOURCE& rhs): m_nr(rhs.m_nr), m_strLocalName(rhs.m_strLocalName), m_strRemoteName(rhs.m_strRemoteName), m_strComment(rhs.m_strComment), m_strProvider(rhs.m_strProvider) { m_nr.lpLocalName = new TCHAR [m_strLocalName.size() + 1]; _tcscpy(m_nr.lpLocalName, m_strLocalName.c_str()); m_nr.lpRemoteName = new TCHAR [m_strRemoteName.size() + 1]; _tcscpy(m_nr.lpRemoteName, m_strRemoteName.c_str()); m_nr.lpComment = new TCHAR [m_strComment.size() + 1]; _tcscpy(m_nr.lpComment, m_strComment.c_str()); m_nr.lpProvider = new TCHAR [m_strProvider.size() + 1]; _tcscpy(m_nr.lpProvider, m_strProvider.c_str()); } ~CNETRESOURCE() { delete [] m_nr.lpLocalName; delete [] m_nr.lpRemoteName; delete [] m_nr.lpComment; delete [] m_nr.lpProvider; } public: NETRESOURCE* operator &() {

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #14

          If it's a vector of CNETRESOURCE, then maybe the problem is absence of operator NETRESOURCE in CNETRESOURCE, but to be honest, I'm guessing because I can't test it. Christian I have come to clean zee pooollll. - Michael Martin Dec 30, 2001

          Sonork ID 100.10002:MeanManOz

          I live in Bob's HungOut now

          M 1 Reply Last reply
          0
          • C Christian Graus

            If it's a vector of CNETRESOURCE, then maybe the problem is absence of operator NETRESOURCE in CNETRESOURCE, but to be honest, I'm guessing because I can't test it. Christian I have come to clean zee pooollll. - Michael Martin Dec 30, 2001

            Sonork ID 100.10002:MeanManOz

            I live in Bob's HungOut now

            M Offline
            M Offline
            Mario M
            wrote on last edited by
            #15

            CNETRESOURCE does have an operator NETRESOURCE...:(( else it would not compile in VC++ 6.0 Thanks for your time. - Mario

            1 Reply Last reply
            0
            • M Mario M

              I have modified the post to 'as-is'. And here is the vector class... also you can read again the previous message with 'as-is'... class CSelectComputerNetwork { public: CSelectComputerNetwork(); virtual ~CSelectComputerNetwork(); public: static bool GetDomains(vector >& vecstrDomains); static bool GetServers(const basic_string& strDomain, vector >& vecstrServers); private: //NETRESOURCE structure wrapper used to save text data that freed by WNetEnumClose(_); class CNETRESOURCE { public: CNETRESOURCE(const NETRESOURCE& nr): m_nr(nr) { m_strLocalName = nr.lpLocalName ? nr.lpLocalName : _T(""); m_strRemoteName = nr.lpRemoteName ? nr.lpRemoteName : _T(""); m_strComment = nr.lpComment ? nr.lpComment : _T(""); m_strProvider = nr.lpProvider ? nr.lpProvider : _T(""); m_nr.lpLocalName = new TCHAR [m_strLocalName.size() + 1]; _tcscpy(m_nr.lpLocalName, m_strLocalName.c_str()); m_nr.lpRemoteName = new TCHAR [m_strRemoteName.size() + 1]; _tcscpy(m_nr.lpRemoteName, m_strRemoteName.c_str()); m_nr.lpComment = new TCHAR [m_strComment.size() + 1]; _tcscpy(m_nr.lpComment, m_strComment.c_str()); m_nr.lpProvider = new TCHAR [m_strProvider.size() + 1]; _tcscpy(m_nr.lpProvider, m_strProvider.c_str()); } CNETRESOURCE(const CNETRESOURCE& rhs): m_nr(rhs.m_nr), m_strLocalName(rhs.m_strLocalName), m_strRemoteName(rhs.m_strRemoteName), m_strComment(rhs.m_strComment), m_strProvider(rhs.m_strProvider) { m_nr.lpLocalName = new TCHAR [m_strLocalName.size() + 1]; _tcscpy(m_nr.lpLocalName, m_strLocalName.c_str()); m_nr.lpRemoteName = new TCHAR [m_strRemoteName.size() + 1]; _tcscpy(m_nr.lpRemoteName, m_strRemoteName.c_str()); m_nr.lpComment = new TCHAR [m_strComment.size() + 1]; _tcscpy(m_nr.lpComment, m_strComment.c_str()); m_nr.lpProvider = new TCHAR [m_strProvider.size() + 1]; _tcscpy(m_nr.lpProvider, m_strProvider.c_str()); } ~CNETRESOURCE() { delete [] m_nr.lpLocalName; delete [] m_nr.lpRemoteName; delete [] m_nr.lpComment; delete [] m_nr.lpProvider; } public: NETRESOURCE* operator &() {

              T Offline
              T Offline
              Tim Smith
              wrote on last edited by
              #16

              The two NETRESOURCE operators need to be removed. They will cause all sorts of problems with standard STLs

                NETRESOURCE\* operator &() 
                  {
                      return &m\_nr;
                  }
              
                  operator NETRESOURCE() const
                  {
                      return m\_nr;
                  }
              

              Specificall,y the operator & is causing the problems. The & operator is used heavily in standard STL. When STL applies the & operator, it is expecting a reference to the class, not a NETRESOURCE *, thus the problem. Tim Smith Descartes Systems Sciences, Inc.

              M 1 Reply Last reply
              0
              • T Tim Smith

                The two NETRESOURCE operators need to be removed. They will cause all sorts of problems with standard STLs

                  NETRESOURCE\* operator &() 
                    {
                        return &m\_nr;
                    }
                
                    operator NETRESOURCE() const
                    {
                        return m\_nr;
                    }
                

                Specificall,y the operator & is causing the problems. The & operator is used heavily in standard STL. When STL applies the & operator, it is expecting a reference to the class, not a NETRESOURCE *, thus the problem. Tim Smith Descartes Systems Sciences, Inc.

                M Offline
                M Offline
                Mario M
                wrote on last edited by
                #17

                Thanks! :), this removes the error, but now I have to find something to replace the operator, since I get this error... SelectComputerNetwork.cpp(58) : error C2664: 'CSelectComputerNetwork::EnumServers' : cannot convert parameter 1 from 'CSelectComputerNetwork::CNETRESOURCE *' to 'NETRESOURCE *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast - Mario

                T 1 Reply Last reply
                0
                • M Mario M

                  Thanks! :), this removes the error, but now I have to find something to replace the operator, since I get this error... SelectComputerNetwork.cpp(58) : error C2664: 'CSelectComputerNetwork::EnumServers' : cannot convert parameter 1 from 'CSelectComputerNetwork::CNETRESOURCE *' to 'NETRESOURCE *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast - Mario

                  T Offline
                  T Offline
                  Tim Smith
                  wrote on last edited by
                  #18

                  Just make a new routine to get that resource. IMHO, I don't understand why NETRESOURCE was made private when the operator & provided unrestricted access to the member. I would just make NETRESOURCE public and be done with it. Tim Smith Descartes Systems Sciences, Inc.

                  M 1 Reply Last reply
                  0
                  • T Tim Smith

                    Just make a new routine to get that resource. IMHO, I don't understand why NETRESOURCE was made private when the operator & provided unrestricted access to the member. I would just make NETRESOURCE public and be done with it. Tim Smith Descartes Systems Sciences, Inc.

                    M Offline
                    M Offline
                    Mario M
                    wrote on last edited by
                    #19

                    I will try to make a new routine to get NETRESOURCE, I also made NETRESOURCE & CNETRESOURCE public, but I get the same error... Thanks for your time.

                    T 1 Reply Last reply
                    0
                    • M Mario M

                      I will try to make a new routine to get NETRESOURCE, I also made NETRESOURCE & CNETRESOURCE public, but I get the same error... Thanks for your time.

                      T Offline
                      T Offline
                      Tim Smith
                      wrote on last edited by
                      #20

                      Yeah, all you will have to do is change those (*ix) to something like (*ix) .m_nr or (*ix) .GetNetResource (). Tim Smith Descartes Systems Sciences, Inc.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups