Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COHey Kiril, thanks for the comprehensive answer, I was able to figure out what's wrong from my original problem. However, I am not able to get the result thing working properly. I created an integer "ans" in my main and set it equal to addobj.add(num1, num2). Then in another cout, I tried to display "int result." However, I got yet another error. Tried my best to figure out what's wrong, but alas didn't find the error. It says "addobj was not declared in the scope" pointing to the line where I set it equal to the answer integer. As you can see I have clearly specified Addition addobj.
      singulars
    2. CO@Carpetfizz - you need to define `addobj` before using it. Watching your edit, move the line `Addition addobj;` before `int ans=addobj.add(num1,num2);`. Then, to get the **correct** result, first you **must** initialize the `num1` and `num2`, before passing them as arguments. In other words, move the line `int ans=addobj.add(num1,num2);` **after** the last `cin`. And the last thing - `addobj.add(num1,num2);` is unnecessary - you have two calls of `add` - one, that you store the result and this one. Remove this one, leave the one with storing the `ans`.
      singulars
    3. COWow thank you sooo much!!! Worked perfectly! This is great, I'll practice some more with classes so that I can do the things you told in my first time around! Thanks again Kiril, and also everyone else who helped me out :)
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload