I am getting the following two errors, i am lost on how to fix them:
Exc_3.cpp(54) : error C2082: redefinition of formal parameter 'name'
Exc_3.cpp(54) : error C2440: 'initializing' : cannot convert from 'char[]' to 'char'
Here was my original prompt, I think i did part B wrong.....wasn't sure how to pass the address of it.
a. Write a function that passes a box structure by value and that displays the value of
each member.
b. Write a function that passes the address of a box structure and that sets the volume
member to the product of the other three dimensions.
c. Write a simple program that uses these two functions.
//Exc_3.cpp - Box structure with functions
#include<iostream>
#include<string>
using namespace std;
struct box
{
char maker[40];
float height;
float width;
float length;
float volume;
};
void displayBox(string name);
void createNewBox(char maker[], float height, float width, float length);
void passAddressBox(string name);
int main()
{
cout << "Let's make a box!" << endl;
float width, height, length;
char maker[40];
cout << "Name of box: ";
cin >> maker;
string name = maker;
cout << "Height of box: ";
cin >> height;
cout << "Length of box: ";
cin >> length;
cout << "Width of box: ";
cin >> width;
createNewBox(maker, height, width, length);
displayBox(name);
cout << "Now box will be different!" << endl;
passAddressBox(name);
displayBox(name);
system("PAUSE");
}
void displayBox(box variable)
{
cout << "Maker: " << variable.maker << endl;
cout << "Height: " << variable.height << endl;
cout << "Width: " << variable.width << endl;
cout << "Length: " << variable.length << endl;
cout << "Volume: " << variable.volume << endl;
}
void createNewBox(string name, char maker[], float height, float width, float length)
{
box name = {maker, height, width, length, 0.0};
}
void passAddressBox(box temp)
{
float temporary = temp.length * temp.height * temp.width;
temp.volume = temporary;
}
Thanks for the help.