Hello,
I am receiving the following error: error C2065: 'to_binary' : undeclared identifier
while running the code below.
If anyone can help I'll appreciate it?
Thank you,
Tukeind
// File: fractal.cxx
// A demonstration program for the random_fractal function from Chapter 9.
#include <cassert> // Provides assert
#include <cstdlib> // Provides EXIT_SUCCESS
#include <iostream.h> // Provides cin, cout
#include "useful.h" // From Appendix H. Provides random_real, display
//using namespace std;
// PROTOTYPE for the function used in this demonstration program.
void random_fractal
(double left_height, double right_height, double width, double epsilon);
// Precondition: width and epsilon are both positive.
// Postcondition: The function has generated a random fractal from a line
// segment. The parameters left_height and right_height are the heights of the
// two endpoints of the line segment, and the parameter width is the segment's
// width. The generation of the random fractal stops when the width of the
// line segments reaches epsilon or less.
// Method of displaying the output: The height of the right endpoint of
// each line segment in the random fractal is displayed by calling the
// function display(...).
int main( )
{
cout << "The decimal number 10 equals ";
to_binary( 10 );
cout << " binary." << endl;
cout << "The decimal number 100 equals ";
to_binary( 100 );
cout << " binary." << endl;
cout << "The decimal number 1000 equals ";
to_binary( 1000 );
cout << " binary." << endl;
cout << "The decimal number 10000 equals ";
to_binary( 10000 );
cout << " binary." << endl;
return EXIT_SUCCESS;
}
void to_binary(int number)
{
if( number == 10)
return;
to_binary( number / 2);
cout << number % 2;
}
I am receiving the following error: error C2065: 'to_binary' : undeclared identifier
while running the code below.
If anyone can help I'll appreciate it?
Thank you,
Tukeind
// File: fractal.cxx
// A demonstration program for the random_fractal function from Chapter 9.
#include <cassert> // Provides assert
#include <cstdlib> // Provides EXIT_SUCCESS
#include <iostream.h> // Provides cin, cout
#include "useful.h" // From Appendix H. Provides random_real, display
//using namespace std;
// PROTOTYPE for the function used in this demonstration program.
void random_fractal
(double left_height, double right_height, double width, double epsilon);
// Precondition: width and epsilon are both positive.
// Postcondition: The function has generated a random fractal from a line
// segment. The parameters left_height and right_height are the heights of the
// two endpoints of the line segment, and the parameter width is the segment's
// width. The generation of the random fractal stops when the width of the
// line segments reaches epsilon or less.
// Method of displaying the output: The height of the right endpoint of
// each line segment in the random fractal is displayed by calling the
// function display(...).
int main( )
{
cout << "The decimal number 10 equals ";
to_binary( 10 );
cout << " binary." << endl;
cout << "The decimal number 100 equals ";
to_binary( 100 );
cout << " binary." << endl;
cout << "The decimal number 1000 equals ";
to_binary( 1000 );
cout << " binary." << endl;
cout << "The decimal number 10000 equals ";
to_binary( 10000 );
cout << " binary." << endl;
return EXIT_SUCCESS;
}
void to_binary(int number)
{
if( number == 10)
return;
to_binary( number / 2);
cout << number % 2;
}
Comment