-3
#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()。然后我调用color()并重main命名了它的参数,它应该复制dollar到函数中并返回它,但事实并非如此。这是怎么回事?

4

1 回答 1

2

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

于 2013-05-31T20:23:13.943 回答