warning c4700

This is a discussion on warning c4700 within the C++ Programming forums, part of the General Programming Boards category; Code: #include "stdafx.h" #include <iostream> #include <fstream> #include <cmath> using namespace std; void input_rect(double,double); double const pi = atan(1.0); int ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    4

    warning c4700

    Code:
    #include "stdafx.h"
    #include <iostream>
    #include <fstream>
    #include <cmath>
    using namespace std;
    
    void input_rect(double,double);
    double const pi = atan(1.0);
    
    int main()
    {
    
    	int choice;
    	double ReA, ImA;
    	do 
    	{
    		cout << "Complex number A: Real: " << ReA << " Imaginary: " << ImA << endl << endl;
    		cout << "1. Enter Complex Number A in Rectangular Form \n";
    		cout << "2. Enter Complex Number A in Polar Form \n"; 
    		cout << "3. Enter Complex Number B in Rectangular Form \n"; 
    		cout << "4. Enter Complex Number B in Polar Form  \n"; 
    		cout << "5. Add the two Complex Numbers: C = A + B \n"; 
    		cout << "6. Find the Complex Conjugate: C = A* \n"; 
    		cout << "7. Multiply the two Complex Numbers: C = AB \n"; 
    		cout << "8. Divide the two Complex Numbers:  C = A / B \n"; 
    		cout << "9. Quit \n \n"; 
    		cout << "make a selection: ";
    		cin >> choice;
    		
    		switch (choice)
    		{
    			case 1: cout << "chose 1 \n \n";
    			{
    				input_rect(ReA,ImA);
    				break;
    			}
    			case 2: cout << "chose 2 \n" << endl; break;
    			case 3: cout << "chose 3 \n" << endl; break;
    			case 4: cout << "chose 4 \n" << endl; break;
    			case 5: cout << "chose 5 \n" << endl; break;
    			case 6: cout << "chose 6 \n" << endl; break;
    			case 7: cout << "chose 7 \n" << endl; break;
    			case 8: cout << "chose 8 \n" << endl; break;
    		}
    	}
    	while (choice !=9);
    	system ("pause");    
    	return 0;
    }
    void input_rect(double Real, double Imag)
    {
    	cout << "Enter real part: ";
    	cin >> Real;
    	cout << "Enter Imaginary part: ";
    	cin >> Imag;
    	cout << endl;
    }

  2. #2
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    681
    What's the question?

    warning c4700 - Szukaj w Google

    Uninitialized:

    double ReA, ImA;
    I never put signature, but I decided to make an exception.

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    4
    what does it mean by it's uninitialized?

    When I assign it values, they stay that value when i need it to change

  4. #4
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    681
    Code:
    double ReA, ImA;
    do 
    {
    	cout << "Complex number A: Real: " << ReA << " Imaginary: " << ImA << endl << endl;
    In the above code, ReA and ImA are printed when they have no value assigned yet. Well, they WILL contain some numbers, but these numbers will be random, which is not desired. C++ does not assign any value to local variables, you have to it on your own:

    Code:
    double ReA = 0, ImA = 1;
    I never put signature, but I decided to make an exception.

  5. #5
    Registered User
    Join Date
    Mar 2011
    Posts
    4
    I put numbers in for those value, but they stay that value, they won't change when the user inputs a new number for them in the function call
    Last edited by whatever125; 03-06-2011 at 02:33 PM.

  6. #6
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    Reasearch the difference between "pass-by-value" and "pass-by-reference". If you change your function from by-value to by-reference, it should work.

    You may want to remove #include "stdafx.h" as you don't need it in your case. That's just unneccessary crap added by your compiler.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  7. #7
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,299
    Quote Originally Posted by whatever125 View Post
    what does it mean by it's uninitialized?

    When I assign it values, they stay that value when i need it to change
    With that program they'll keep the values they had regardless of whether you initialise them or not.

    Google Pass By Reference
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined reference to.. probably Makefile problem
    By mravenca in forum C Programming
    Replies: 11
    Last Post: 10-20-2010, 04:29 AM
  2. Replies: 2
    Last Post: 09-16-2009, 06:00 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 12:03 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21