gpt4 book ai didi

c - 错误: redefinition of random and related compiler errors

转载 作者:行者123 更新时间:2023-11-30 20:57:00 25 4
gpt4 key购买 nike

#import <Foundation/Foundation.h>

struct {
double x;
float yellow;
double number;

}budget;
struct budget random; //error: redefinition of random

void color(dollar){

random.number = random.x - dollar; //error member referance has a base type long(void)not a structure or union.

}

int main(int argc, const char * argv[]){


random.x = 10;//error member referance has a base type long(void)not a structure or union.
random.yellow = 1.4;//error member referance has a base type long(void)not a structure orunion
int dollar = 4;
color(newNumber); use of undeclared variable new number.

NSLog(@"the total budget is %.2f", random.number); //error member referance has a base type long(void)not a structure or union.

return 0 ;
}

我正在关注 Objective-C 的视频教程:http://www.youtube.com/watch?v=RsXivZEU9rc&list=SP54515103C712A53D&index=19 ,并且我已经尝试了我能想到的所有方法,但是此代码不会返回 random.number 总计,这将是 random.x-dollar 如中所述函数color()。然后,我在 main 中调用 color() 并重命名了它的参数,它应该在函数中复制 dollar 并返回它,但事实并非如此。这是怎么回事?

最佳答案

我因为工作原因无法观看视频,但你正在重新定义“随机”。尝试用其他名称替换变量“随机”。其余的错误只是从第一个错误(您对随机的重新定义)开始级联。

关于c - 错误: redefinition of random and related compiler errors,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16865315/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com