これがコード全体です。コンパイルすると、次のエラーが表示されます。
エラー LNK2019: 未解決の外部シンボル "void __cdecl CandyBarFunc(struct CandyBar &,char const *,double,int)" (?CandyBarFunc@@YAXAAUCandyBar@@PBDNH@Z) 関数 _wmain で参照
致命的なエラー LNK1120: 1 つの未解決の外部
#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;
}