Adding 2 object fields

I'm trying to add two object fields and assign the total to sum:

int sum = ((objmilli.millimeters) + (objcenti.centimeters));

I keep getting an error. Can you tell me what's wrong with my syntax ?

Thanks.....

Pete

Comments

  • Maybe it would be nice to send in the error message as well... And I question what the purpose of adding centimeters and millimeters might be...

    Besides all that, check the following:
    - you have a rightly instantiated object objcenti
    - you have a rightly instantiated object objmilli
    - both contain the corresponding variables marked [b]public[/b]
    - both are integers (typed [b]int[/b]
  • The error message would be a great help but a possibility (not the only one but a common one) might be that the fields are declared as private.


    Kind Regards
    Konrad
    ----------------------------
    (+46/0) 708-70 73 92
    [email protected]
    http://konrads.webbsida.com

  • I figured out my problem.... It wasn't syntactical....

    Thanks for the reply though....

    Pete

    : Maybe it would be nice to send in the error message as well... And I question what the purpose of adding centimeters and millimeters might be...
    :
    : Besides all that, check the following:
    : - you have a rightly instantiated object objcenti
    : - you have a rightly instantiated object objmilli
    : - both contain the corresponding variables marked [b]public[/b]
    : - both are integers (typed [b]int[/b]
    :

  • I figured out my problem.... It wasn't syntactical....

    Thanks for the reply though....

    Pete

    : The error message would be a great help but a possibility (not the only one but a common one) might be that the fields are declared as private.
    :
    :
    : Kind Regards
    : Konrad
    : ----------------------------
    : (+46/0) 708-70 73 92
    : [email protected]
    : http://konrads.webbsida.com
    :
    :

  • One more thing... I know the problem is a little abnormal, by adding two different units of measurement, but that's what we're asked to do... So I just do it :)

    Pete

    : Maybe it would be nice to send in the error message as well... And I question what the purpose of adding centimeters and millimeters might be...
    :
    : Besides all that, check the following:
    : - you have a rightly instantiated object objcenti
    : - you have a rightly instantiated object objmilli
    : - both contain the corresponding variables marked [b]public[/b]
    : - both are integers (typed [b]int[/b]
    :

  • Nice to hear.



    Kind Regards
    Konrad
    ----------------------------
    (+46/0) 708-70 73 92
    [email protected]
    http://konrads.webbsida.com

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories