Objective-cについてもう少し勉強しようとしています。私は4つのエラー、すべて同じです。 "関数の暗黙の宣言"、私はそれを見つけたが、私は解決策を見つけることができませんでした。目的関数cの暗黙の宣言に伴う問題
RadioStationの.h
#import <Cocoa/Cocoa.h>
@interface RadioStation : NSObject {
NSString* name;
double frequency;
char band;
}
+(double)minAMFrequency;
+(double)maxAMFrequency;
+(double)minFMFrequency;
+(double)maxFMFrequency;
-(id)initWithName:(NSString*)newName atFrequency:(double)newFrequency withBand:(char)newBand;
-(NSString*)name;
-(double)frequency;
-(char)band;
-(void)setName:(NSString*)newName;
-(void)setFrequency:(double)newFrequency;
-(void)setBand:(char)newBand;
@end
RadioStation .M
#import "RadioStation.h"
@implementation RadioStation
+(double)minAMFrequency{
return 520.0;
};
+(double)maxAMFrequency{
return 1610.0;
};
+(double)minFMFrequency{
return 88.3;
};
+(double)maxFMFrequency{
return 107.9;
};
-(id)initWithName:(NSString*)newName atFrequency:(double)newFrequency withBand:(char)newBand{
self = [super init];
if(self != nil){
name = [newName retain];
band = newBand;
if (band == 'F') {
if (newFrequency > maxFMFrequency()) {
frequency = maxFMFrequency();
}else if (newFrequency < minFMFrequency()) {
frequency = minFMFrequency();
}else {
frequency = newFrequency;
}
}else if (band == 'A') {
if (newFrequency > maxAMFrequency()) {
frequency = maxAMFrequency();
}else if (newFrequency < minAMFrequency()) {
frequency = minAMFrequency();
}else {
frequency = newFrequency;
}
}
}
return self;
}
@end
ライン
if (newFrequency > maxFMFrequency()) {
if (newFrequency < minFMFrequency()) {
if (newFrequency > maxAMFrequency()) {
if (newFrequency < minAMFrequency()) {
すべては、事前に
ありがとう "機能の暗黙の宣言" を言いますダイエッガー
の下に与えられたとして、関数呼び出しを変更することでソートこれは、バイナリに無効なオペランドを返した> –
うーん...多分マークまたはtheChrisは理由として私たちを啓発することができます。それは私からの投票の価値があるでしょう! – Dave
問題は、上記のようにメソッドがインスタンスメソッドであるかのようにメソッドにアクセスすると、ポインタが返され、コンパイラはバイナリ操作を実行することを前提としています。 >はバイナリ演算子ではないので、そのエラーをスローします。私はあなたの努力に感謝しますが、上記のコメントのOPで述べたようにこの答えは正しいわけではありません。あなたの幸運な日でなければならない! :) – theChrisKent