[*在结构函数中是什么?

问题描述 投票:-1回答:1
struct Node *addToEmpty(struct Node *last, int data) 
{ 
// This function is only for empty list 
if (last != NULL) 
  return last; 

// Creating a node dynamically. 
struct Node *temp =  
       (struct Node*)malloc(sizeof(struct Node)); 

// Assigning the data. 
temp -> data = data; 
last = temp; 

// Creating the link. 
last -> next = last; 

return last; 
} 

struct Node *addBegin(struct Node *last, int data) 
{ 
if (last == NULL) 
    return addToEmpty(last, data); 

struct Node *temp =  
        (struct Node *)malloc(sizeof(struct Node)); 

temp -> data = data; 
temp -> next = last -> next; 
last -> next = temp; 

return last; 
} 

我想知道为什么使用“ * addToEmpty”而不是“ addToEmpty”。

“ *”在结构中是什么意思?

我知道这是基本问题。但我找不到答案。

如果您回答我的问题,我今天会过得很好

P.S。这是c ++代码。

c++ struct syntax
1个回答
0
投票

了解C ++中的指针。如何pointer


0
投票

这是C(++)的A和B [Pun意图]。

您正在要求我们教您指针的基础知识。看看https://en.cppreference.com/w/cpp/language/pointer或Google“在C ++中使用指针”,将对所有内容进行说明。

© www.soinside.com 2019 - 2024. All rights reserved.