C ++ function call issuance of parameter delivery

xiaoxiao2021-04-05  276

This is a problem that I have encountered when I have a procedure in the morning. First look error code: void TestSelect (CMysqlDBTools myDBtools) {vector info; string query = "select bc_id, b_title from board"; myDBtools.SetQuerySQL (query); myDBtools.ExcuteQuery (); info = myDBtools. GetVecRecords ();

For (int i = 0; I

Int main () {CMYSQLDBTools MyDbtools ("172.30.27.188", "user", "password", 3306); mydbtools.connect (); mydbtools.selectDatabase ("hwalk_test"); testselect (mydbtools);

Return 1;} First get the database online tool, then test the SELECT function of this tool. MydbTools passes the value. There is no problem in the entire output execution process, but the exception is read during the end of the program. After analysis, it is ~ CMYSQLDBTools () calls two -TestSelect () End Tune once, main () ends at the end, the second call, because the pointer has point to NULL, so error. It can be seen that when passing the object parameters in C , the object is a shallow copy, the pointer in the object points to the same address, and the epitome should be noticed. The above procedure is made as follows, and there is no problem with the pointer or reference delivery parameters. Pointer: void TestSelect (CMysqlDBTools * pMyDBtools) {vector info; string query = "select bc_id, b_title from board"; myDBtools-> SetQuerySQL (query); myDBtools-> ExcuteQuery (); info = myDBtools-> GetVecRecords ( );

For (int i = 0; I

int main () {CMysqlDBTools myDBtools ( "172.30.27.188", "user", "password", 3306); myDBtools.Connect (); myDBtools.SelectDatabase ( "hwalk_test"); TestSelect (& myDBtools); return 1;} references : void TestSelect (CMysqlDBTools & myDBtools) {vector info; string query = "select bc_id, b_title from board"; myDBtools.SetQuerySQL (query); myDBtools.ExcuteQuery (); info = myDBtools.GetVecRecords (); for (int i = 0; I

Int main () {

CMYSQLDBTools MyDbtools ("172.30.27.188", "User", "Password", 3306); mydbtools.connect (); mydbtools.selectDatabase ("hwalk_test"); testselect (mydbtools);

Return 1;}

转载请注明原文地址:https://www.9cbs.com/read-132193.html

New Post(0)