I am stuck once again.
Code:
// reference prblm. 2 pg368 c++ primer plus
#include <iostream>
using namespace std;
struct candybar
{
char name[20];
double weight;
int calories;
};
// prototypes passing by refrence
candybar & set(candybar & candyref,char * brand="Hershy",double weigh=2.85,int cal=350);
void show(const candybar & candyref);
int main()
{
candybar def
{
"none",
0.0,
0
};
show(set(def));
return 0;
}
candybar & set(candybar & candyref,char * brand="Hershy",double weigh=2.85,int cal=350)
{
candyref.name=*brand;
candyref.weight=weigh;
candyref.calories=cal;
return candyref;
}
void show(const candybar & candyref)
{
cout << "Candybar\n";
cout << "Brand name:"<<candyref.name<<endl;
cout << "Weight:"<<candyref.weight<<endl;
cout << "Calories:"<<candyref.calories<<endl;
}
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
ref.cpp:
Error E2108 ref.cpp 19: Improper use of typedef 'candybar' in function main()
* cant figure out this prblw
Error E2379 ref.cpp 19: Statement missing ; in function main()
* cant find the missing ;
Error E2451 ref.cpp 25: Undefined symbol 'def' in function main()
Error E2148 ref.cpp 30: Default argument value redeclared for parameter 'brand'
Error E2277 ref.cpp 31: Lvalue required in function set(candybar &,char *,double
,int)
Warning W8057 ref.cpp 35: Parameter 'brand' is never used in function set(candyb