关于C++中的错误:error C2501: 'base' : missing storage-class or type specifiers
#include<stdio.h>#include<stdlib.h>#include<malloc.h>#include<iostream.h>typedefstruc...
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <iostream.h>
typedef struct Matrix{
int i;
int j;
int e;
struct Matrix *nexti;
struct Matrix *nextj;
}Matrix;
struct Matrix *p;
struct Matrix *q;
struct Matrix *base;
base=(struct Matrix *)malloc(sizeof(Matrix));
出现错误:
C:\Documents and Settings\Administrator\Desktop\实验1%2\实验1%2\魔方阵\魔方阵.cpp(19) : error C2501: 'base' : missing storage-class or type specifiers
C:\Documents and Settings\Administrator\Desktop\实验1%2\实验1%2\魔方阵\魔方阵.cpp(19) : error C2040: 'base' : 'int' differs in levels of indirection from 'struct Matrix *'
C:\Documents and Settings\Administrator\Desktop\实验1%2\实验1%2\魔方阵\魔方阵.cpp(19) : error C2440: 'initializing' : cannot convert from 'struct Matrix *' to 'int'
错误都是指向base=(struct Matrix *)malloc(sizeof(Matrix));这句的 展开
#include <stdlib.h>
#include <malloc.h>
#include <iostream.h>
typedef struct Matrix{
int i;
int j;
int e;
struct Matrix *nexti;
struct Matrix *nextj;
}Matrix;
struct Matrix *p;
struct Matrix *q;
struct Matrix *base;
base=(struct Matrix *)malloc(sizeof(Matrix));
出现错误:
C:\Documents and Settings\Administrator\Desktop\实验1%2\实验1%2\魔方阵\魔方阵.cpp(19) : error C2501: 'base' : missing storage-class or type specifiers
C:\Documents and Settings\Administrator\Desktop\实验1%2\实验1%2\魔方阵\魔方阵.cpp(19) : error C2040: 'base' : 'int' differs in levels of indirection from 'struct Matrix *'
C:\Documents and Settings\Administrator\Desktop\实验1%2\实验1%2\魔方阵\魔方阵.cpp(19) : error C2440: 'initializing' : cannot convert from 'struct Matrix *' to 'int'
错误都是指向base=(struct Matrix *)malloc(sizeof(Matrix));这句的 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询