C语言 结构体嵌套 中的问题,

问题还没有解决。。。[请看到的老师们 帮忙看看,谢谢,麻烦了]

等待中~

图片说明我大概的想法是用结构体嵌套,

嗯~ 打个比喻, 班上每个同学的学号是外结构体的数据, 之后用学号来找同学。

每个同学的各科成绩是内结构体。

我现在想做一个同学个各科成绩录入, 可是在科目一 链接 科目二 在这儿错了,

图中是DeV C++ 编译软件

而VC++ 报错是:E:\C\GG\GGGG.CPP(42) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct date *' (or there is no acceptable conversion)

如果把图中阴影部分改为: head->full = * front; 则不报错。

希望老师们 说下如何解决, 以及为何该为 head->full = * front; 之后不报错,却会终止程序,[ 其中的问题是什么 ]

刚刚创建的CSDN账号,没有财富值,-。-

图片说明

老师, 不怎么会动态分配 啊。。。

typedef struct date{
int prestoreboole; // 1/0 进行位与运算;与grade中boole 相同;
int cut; // 代表时候被删掉,1代表删掉,0代表不被删掉。
struct date *neinext; // 内表中的指针域

}Date,*linklist;

typedef struct grade{
int boole;
int number;
double result;
struct date *full;

struct grade *next;
}Grade,*LinkList;

struct grade *Copy( struct grade *prestorehead , struct grade *originalhead){

struct grade *neworiginalhead = originalhead; 
struct grade *newprestorehead = prestorehead; 
struct date *front = NULL , *newpoint;
LinkList head;

do{ 
//******************************************************************************
front = (linklist)malloc(sizeof(Date));     //     [     这是我刚刚加的,是这样分配吗?     老师您能凑合这些代码,  分配一下,标注出来吗?]

//*******************************************************************






newpoint = (linklist)malloc(sizeof(Date)); 
newpoint->prestoreboole = neworiginalhead->boole;
newpoint->neinext = NULL;

        if( front == NULL ){
            front = newpoint;
            head->full = front;     
        }else{
          front->neinext = newpoint->neinext;
          front = front->neinext;

        }
neworiginalhead = neworiginalhead->next;

}while(neworiginalhead != NULL);
head->full->cut = 1;  //  这是第一个数,需要删除   
return head;

}

你定义的grade中的full 是 struct data 类型的,阴影处你却将,strcut data *类型的front赋给了 struct data 类型,所以会报error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct date *' (or there is no acceptable conversion)
建议将grade中的full 改为 struct data *类型的,注意动态分配内存

binary '=' : no operator defined 提示你没有定义拷贝赋值

head/front是指向 grade 结构体的指针,而成员 full 是 date 结构的引用,当代码这样写时,就意味将指针赋值给引用,在C++中是不存在这样的操作的,所以提示要求实现这样的赋值定义:

head->full = front;

这就编译程序为什么提示“binary '=' : no operator defined”

参考《那年声明理解不了定义与初始化(三)》指针与引用部分的内容 - http://blog.csdn.net/winsenjiansbomber/article/details/50659505

这是动态分配:front = (linklist)malloc(sizeof(Date));
但是其实这一步可以不用,因为newpoint = (linklist)malloc(sizeof(Date)); 已经分配过了