Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 999799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:24:38+00:00 2026-05-16T07:24:38+00:00

operator class: #import <Foundation/Foundation.h> @interface operator : NSObject { int number; } @property int

  • 0

operator class:

#import <Foundation/Foundation.h>


@interface operator : NSObject {

int number;
}

@property int number;

@end

@implementation operator

- (id)init{
    self = [super init];
    if (self) {
    [self setNumber:0];
    }
    return self;
}

@synthesize number;
@end

main.m:

#import <UIKit/UIKit.h>
#import "operator.m"

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

id operator1 = [[operator alloc] init];
id operator2 = [[operator alloc] init];

[operator1 setNumber:10];
[operator2 setNumber:20];

int answer = [operator1 number] + [operator2 number];

printf("The answer is %d",answer);



NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}

I get an error -> ld: duplicate symbol _OBJC_IVAR_$_operator.number in /Volumes/Home/Desktop/testing/build/testing.build/Debug-iphonesimulator/testing.build/Objects-normal/i386/operator.o and /Volumes/Home/Desktop/testing/build/testing.build/Debug-iphonesimulator/testing.build/Objects-normal/i386/main.o

This is my very first time I program in ObjC. Am I doing something wrong?

I tried the “Clean all targets” fix that I found on google but did not help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T07:24:38+00:00Added an answer on May 16, 2026 at 7:24 am
    1. You should never #import an .m file into another file. You import the .h file, if it’s needed.
    2. You should not have code executing in main before you create the autorelease pool. That is going to cause problems sooner or later. In this case, you test code should probably go in application:didFininshLaunching instead.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that dynamically overloads basic arithmetic operators like so... import operator
I would like to add an operator to a class. I currently have a
Is it possible to overload the null-coalescing operator for a class in C#? Say
In C++, can you have a templated operator on a class? Like so: class
I have a class that defined a user defined operator for a TCHAR*, like
I've got a simple class Currency with overloaded operator<<. I don't know how can
When you create an instance of a class with the new operator, memory gets
I am trying to write operator overload for custom class and don't know how
In a comparison operator: template<class R1, class R2> bool operator==(Manager<R1> m1, Manager<R2> m2) {
I want to print out a derived class using the operator<< . When I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.