I have a very simple function using overloading function. It's just supposed to send an array to a function, and the function prints out that array "size" times. It's printing it out the correct number of times, but it keeps printing junk. WHat's wrong?
This is what I have so far.
Code:
#include<iostream>
#include<cstdlib>
using namespace std;
void print(const int data[], int size = 10) //int version
{
for(int i = 0; i < size; i++)
cout << "Triple int version: " << data << endl;
}
void print(const float data[], int size = 10) //float version
{
for(int i = 0; i < size; i++) //loop 'size' times
cout << "Triple float version: " << data << endl; //prints the triples-array
}
void print(const char data[], int size = 10) //char version
{
for(int i = 0; i < size; i++) //loop 'size' times
cout << "Triple char version: " << data << endl; //prints the triples-array
}
int main()
{
void print(const int data[], int size = 10); //prototype for int
void print(const float data[], int size = 10); //prototype for float
void print(const char data[], int size = 10); //prototype for char
//generic arrays specific to their respective types
int array_int[5] = {1, 2, 3, 4, 5};
float array_float[5] = {1.123, 2.234, 3.345, 4.456, 5.567};
char array_char[5] = {6, 7, 8, 9, 10};
print(array_int); //Send with int-specific function
print(array_float, 5); //Send to float-specific function
print(array_char, 1); //Send to char-specific function
system("pause");
}