我有這樣的結構:如何在功能檢索指針結構
struct ClientNode
{
string name;
int flightnumber;
int clientno;
ClientNode * right;
ClientNode* left;
};
然後我宣佈這個結構的指針:
ClientNode* root = new ClientNode;
的功能我已經爲初始化clientno根這樣的:
root->clientno = 11;
,然後我想髮根作爲參數傳遞給函數:
ClientNode newnode;
root = Insert_to_AVL_Tree(&newnode, root);
這裏是我Insert_to_AVL_Tree:
ClientNode* clientclass::Insert_to_AVL_Tree(ClientNode* Node, ClientNode* root)
這裏就是錯誤發生,我已經初始化根 - > clientno但它似乎改變了,當我把它傳遞給另一個函數因此可以」牛逼比較值的,如果還節點 - > clientno有一個已經從文件中讀取我的代碼另一部分正確的值:
if (Node->clientno < root->clientno)
root->left = Insert_to_AVL_Tree(Node, root->left);
什麼是讓根 - > clientno的正確方法在另一個函數中的值? here is the value shown for root->clientno
here is the value for node->cleintno
我已經在其他地方初始化它和值是否設置正確。但是root-> clientno的值有如-88845858 – esmaily
你怎麼知道root-> clientno已經改變了?請發佈完整的代碼示例。 – 4386427
爲什麼你需要這個?這是一項任務嗎? –