静态链表:
链表定义在结构体内部:
struct My{
int num;
struct My *next;
}
void main(){
struct My n1,n2,n3,n4;
struct My *head = &n1;
n1.num = 10;
n2.num = 20;
n3.num = 30;
n4.num = 40;
n1.next = &n2;
n2.next = &n3;
n3.next = &n4;
n4.next = NULL;
while(head != NULL){
printf("%d",head->num);
head = head->next;
}
}
C++对象:
定义:
class Point{
public:
private:
}public为公有 可以被访问
private为私有 无法被访问的
转载请注明原文地址: https://ju.6miu.com/read-1311775.html