Hello there. This is obviously my first post on DaniWeb, as I just found the site in searching for a solution to my issue. I've read over the site rules, as well as the forum rules regarding homework help.

Let me start out by saying I am not looking for an easy solution, or some one to do my work. I'm simply trying to figure out why I can't get this darn thing to compile =)

I'm using Visual C++ 2005 Express Edition, and have pretty much just started coding an end-of-chapter lab assignment.

The issue I'm running into has to do with passing an array of my pre-defined struct into another function. The following is my code.

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

struct menuItemType
{
    string menuItem;
    double menuPrice;
};

void getData(menuItemType menu[]);
void showMenu(menuItemType menu[]);
void printCheck(menuItemType menu[]);

int main()
{
    menuItemType menu[8];

    getData(menu);

    return 0;
}

The errors that I am receiving are:

1>Compiling...
1>Breakfast.cpp
1>Linking...
1>Breakfast.obj : error LNK2001: unresolved external symbol "void __cdecl getData(struct menuItemType * const)" (?getData@@YAXQAUmenuItemType@@@Z)
1>C:\Documents and Settings\Luwigie\My Documents\Visual Studio 2005\Projects\Breakfast\Debug\Breakfast.exe : fatal error LNK1120: 1 unresolved externals

Again, this is in the early construction phase, and I don't seem to be having a compiler error... The error seems to come at the linking stage.

Any help would be greatly appreciated. Also, this looks like an excellent site and source of information =) Glad I stumbled upon it.

Recommended Answers

All 3 Replies

The link error is telling you that you forgot to code the function getData(). This is not a standard C function -- you have to write it yourself.

You have done everything right thus far.. the only thing you haven't done, is to provide "function definitions" for your functions.

Below your main( ), go ahead and right up what each function is supposed to do. Here is some pseudo to get ye' started:

void getData(menuItemType menu[])
{
   do stuff...
   ....
   ....
}

make sure each function prototype has an associated function definition and life will == good.

Wow. I appreciate the quick response guys.

This dawned on me right after I posted. Doh!

I don't know why throwing a struct definition made me throw everything I've learned thus far out the window :-|

I appreciate the prompt responses guys! Almost wish I could take down this thread out of embarrasment :rolleyes:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.