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. delete m_pdbf in destruction?

delete m_pdbf in destruction?

Scheduled Pinned Locked Moved C / C++ / MFC
databasesalesquestion
2 Posts 2 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.
  • V Offline
    V Offline
    valerie99
    wrote on last edited by
    #1

    hi, all when this app open the customer dbf file, it creats index as well, it didn't really has m_pdbf = new...., but it seems like need to be deleted in dbCustomer::~dbCustomer(), here is the steps: BOOL dbCustomer::Open( const char *pszFileName, bool bReindex ) { ASSERT( m_pdbf == NULL ); int nError = 0; std::string strErrMsg = ""; if ( !OpenDbfNtx( &m_pdbf, pszFileName, NULL, NULL, nError, &strErrMsg ) ) throw DbfAccessException (string(pszFileName) + " not found", RC_DBF_UNABLE_TO_OPEN); SetIndex( pszFileName, m_pdbf, bReindex ); m_pdbf->set_order( "CUSNUM02" ); return BindFieldOrdinals(); } CB_DBF_NTX* const p = OpenDbfNtxHelper( szDbfName, szIndexName, szIndexKey ); CB_DBF_NTX* pDbf = new CB_DBF_NTX( const_cast( szDbfName ) ); the wrapper seems conplicated, it's getting infor from library files.........thanks for your time

    M 1 Reply Last reply
    0
    • V valerie99

      hi, all when this app open the customer dbf file, it creats index as well, it didn't really has m_pdbf = new...., but it seems like need to be deleted in dbCustomer::~dbCustomer(), here is the steps: BOOL dbCustomer::Open( const char *pszFileName, bool bReindex ) { ASSERT( m_pdbf == NULL ); int nError = 0; std::string strErrMsg = ""; if ( !OpenDbfNtx( &m_pdbf, pszFileName, NULL, NULL, nError, &strErrMsg ) ) throw DbfAccessException (string(pszFileName) + " not found", RC_DBF_UNABLE_TO_OPEN); SetIndex( pszFileName, m_pdbf, bReindex ); m_pdbf->set_order( "CUSNUM02" ); return BindFieldOrdinals(); } CB_DBF_NTX* const p = OpenDbfNtxHelper( szDbfName, szIndexName, szIndexKey ); CB_DBF_NTX* pDbf = new CB_DBF_NTX( const_cast( szDbfName ) ); the wrapper seems conplicated, it's getting infor from library files.........thanks for your time

      M Offline
      M Offline
      Maximilien
      wrote on last edited by
      #2

      depends on your design. if there's an Open method, maybe there's a Close method also that will close the database and delete the object. if you're not certain about that, put the delete in the destructor.


      Maximilien Lincourt Your Head A Splode - Strong Bad

      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