变量由struct声明 [英] variable declare by struct

查看:100
本文介绍了变量由struct声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是将变量x1,x2和x3声明为复杂类型的结构
我可以知道下面的答案正确吗?

my question is declare variable x1, x2 and x3 as structure of type complex
may i know my below answer correct?

struct complex{
   struct complex *x1;
   struct complex *x2;
   struct complex *x2;
};

推荐答案

不是,不是.

这是C代码(不是C ++):

Uhm no, it''s not.

Here''s C code (not C++) :

struct complex
{
    // struct members
    double realPart;
    double imaginaryPart;
};

void Foo()
{
    struct complex x1;
    struct complex x2;
    struct complex x3;
}


号.
struct COMPLEX x1;
struct COMPLEX x2;
struct COMPLEX x3;


如果...


if...

struct COMPLEX{
 double real;
 double imaginary;
};



或...



or...

COMPLEX x1;
COMPLEX x2;
COMPLEX x3;


如果...


if...

typedef struct _COMPLEX_{
 double real;
 double imaginary;
} COMPLEX;


这篇关于变量由struct声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆