Thread: Hello, I need a little explanation of why this happens

  1. #1
    Registered User arti's Avatar
    Join Date
    May 2010
    Posts
    108

    Hello, I need a little explanation of why this happens

    I declared my numeric variables in my program then tried to write those same variables in a function where it adds up all the variables then spits out a total. I get kicked back an error that says that the variable was not declared in this scope
    Code:
    g++ datos.cpp  -o program.exe 
    datos.cpp:8:16: error: variable or field ‘totalCalc’ declared void
    datos.cpp:8:16: error: ‘pago1’ was not declared in this scope
    datos.cpp:8:23: error: ‘pago2’ was not declared in this scope
    datos.cpp:8:30: error: ‘pago3’ was not declared in this scope
    datos.cpp:8:37: error: ‘pago4’ was not declared in this scope
    datos.cpp:8:45: error: ‘total’ was not declared in this scope
    datos.cpp: In function ‘int main()’:
    datos.cpp:42:47: error: ‘totalCalc’ was not declared in this scope
    datos.cpp: At global scope:
    datos.cpp:54:16: error: variable or field ‘totalCalc’ declared void
    datos.cpp:54:16: error: ‘pago1’ was not declared in this scope
    datos.cpp:54:23: error: ‘pago2’ was not declared in this scope
    datos.cpp:54:30: error: ‘pago3’ was not declared in this scope
    datos.cpp:54:37: error: ‘pago4’ was not declared in this scope
    datos.cpp:54:45: error: ‘total’ was not declared in this scope
    make: *** [program.exe] Error 1
    Why is this happening?
    P.S I had written the prototype and call and function definition correctly.

  2. #2
    Registered User arti's Avatar
    Join Date
    May 2010
    Posts
    108
    Nevermind got it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need some explanation here...
    By 0celot in forum C Programming
    Replies: 6
    Last Post: 01-10-2012, 08:46 PM
  2. explanation please
    By JayCee++ in forum C++ Programming
    Replies: 7
    Last Post: 10-04-2011, 04:17 AM
  3. need explanation
    By Ssfccsh in forum C++ Programming
    Replies: 6
    Last Post: 03-01-2004, 01:40 PM
  4. Explanation Please
    By atari400 in forum C++ Programming
    Replies: 2
    Last Post: 04-25-2003, 08:39 AM
  5. Further Explanation
    By sketchit in forum C Programming
    Replies: 1
    Last Post: 09-24-2001, 12:23 PM