-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

私は仕事のためにビデオを見ることができませんが、あなたは「ランダム」を再定義しています. 変数「ran​​dom」を別の名前に置き換えてみてください。残りのエラーは、最初のエラー (ランダムの再定義) から単純にカスケードしています。

于 2013-05-31T20:23:13.943 に答える