首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

"complex" has already been declared in the current scope,该如何解决

2013-06-25 
complex has already been declared in the current scope本帖最后由 yyme411 于 2013-05-27 14:43:11

"complex" has already been declared in the current scope
本帖最后由 yyme411 于 2013-05-27 14:43:11 编辑 请问一下这是什么问题"Mymath.h", line 15: error: "complex" has already been declared in the current scope。应该怎么解决,代码如下

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define TINY 1.0e-20 
#define FREE_ARG char*
#define PI 3.1415926


typedef struct
/*定义复数结构体*/
{
double real ;
double imag ;
}complex;

double Cabs(complex a)
/*求复数的绝对值*/
{
double c;
c=sqrt(a.real*a.real+a.imag*a.imag);
return c;
}
complex Cadd(complex a,complex b)
/* 复数加法*/
{
complex c;
c.real=a.real+b.real;
c.imag=a.imag+b.imag;
return c;
}

这个是Mymath.h中的文件,请问一下这个应该怎么弄? C
[解决办法]
.h 文件如果是 VC 的话, 在第一行加 #pragma once

通用点的话在文件前面加 
#ifndef _MYMATH_H
#define _MYMATH_H
在最后加
#endif

热点排行