Это весь код. После компиляции я получаю ошибку ниже:
ошибка LNK2019: неразрешенный внешний символ «void __cdecl CandyBarFunc (struct CandyBar &, char const *, double, int)» (? CandyBarFunc @@ YAXAAUCandyBar @@ PBDNH @ Z), на который есть ссылка в функции _wmain
фатальная ошибка LNK1120: 1 не устранена
* внешние 1006 *
#include "stdafx.h"
#include <iostream>
using namespace std;
struct CandyBar
{
char name[40];
double weight;
int calories;
};
void CandyBarFunc(CandyBar & astruct, const char * aname = "Millennium Munch", double aweight = 2.85, int acalories = 350);
void CandyBarFunc(const CandyBar & astruct);
int _tmain(int argc, _TCHAR* argv[])
{
CandyBar MyCandyBar;
CandyBarFunc(MyCandyBar, "Hello World Candy Bar", 1.25, 200);
CandyBarFunc(MyCandyBar);
return 0;
}
void CandyBarFunc(CandyBar & astruct, char * aname, double aweight, int acalories)
{
strncpy(astruct.name,aname,40);
astruct.weight = aweight;
astruct.calories = acalories;
}
void CandyBarFunc(const CandyBar & astruct)
{
cout << "Name: " << astruct.name << endl;
cout << "Weight: " << astruct.weight << endl;
cout << "Calories: " << astruct.calories;
}