Passing a data structure by reference causes lnk2019 error

Posted on 2008-10-05
Last Modified: 2013-12-14
I'm pasting the code below, and the function in question at the top again.  
The function immediately below causes the error.  If I pass by value, it doesn't throw the error at me.  I've also posted the error below.


void fnCalculate(userInput& tempVar1){

Error      1      error LNK2019: unresolved external symbol "void __cdecl fnCalculate(struct userInput)" (?fnCalculate@@YAXUuserInput@@@Z) referenced in function "void __cdecl fnGetUserInput(void)" (?fnGetUserInput@@YAXXZ)      main.obj      

#include <iostream>

using namespace std;

struct userInput{

	int units;

	int session;

	int residency;

	char parking;

	char sticker;

	char IDCard;


char fnTryAgain(char);

void fnGetUserInput();

void fnCalculate(userInput);

int main()


	int varAnswer=1;	

	cout << "Programing running..." <<endl;

	cout << "SMC Fee Calculator."<<endl;		

	while (varAnswer == 1)



	varAnswer = fnTryAgain(' ');


	return 0;


void fnGetUserInput()


	userInput strInput;

	cout << "Enter the number of units enrolled: ";

	cin >> strInput.units;

	cout << "Is this Fall[0], Winter[1], Spring[2] or Summer[3]: ";

	cin >> strInput.session;

	cout << "Are you a state resident[0], non-resident[1] or F1 Visa holder[2]: ";

	cin >> strInput.residency;

	cout << "Do you want a parking decal [y/n]: ";

	cin >> strInput.parking;

	cout << "Do you want an AS sticker [y/n]: ";

	cin >> strInput.sticker;

	cout << "Do you want an ID card [y/n]: ";

	cin >> strInput.IDCard;



void fnCalculate(userInput& tempVar1){


char fnTryAgain(char varReply2)


	char varReply1=' ', varReply=' ';

	cout << endl << endl << "Try another scenario?  Enter n for no, any other key for yes: ";

	cin >> varReply1;

	if (varReply1 == 'n'){

		varReply = 0;


	else if (varReply1 == 'N'){

		varReply = 0;



		varReply = 1;

	return varReply;


Open in new window

Question by:mike_hale
  • 2
LVL 55

Accepted Solution

Jaime Olivares earned 500 total points
ID: 22644382
both the declaration of the function and the implementation must match the same type of arguments.
So, your declaration at line 13:

     void fnCalculate(userInput);

should be:

     void fnCalculate(&userInput);

to match the implementation at line 44

Author Comment

ID: 22645622
*slaps forehead*

Duh!  That worked.  Thank you Jaime!  

Author Closing Comment

ID: 31503150
Thank you!  

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now