error LNK2019

help me with the error below, I do not know where to find the symbol which causes this error.

Error 16 error LNK2019: unresolved external symbol "void __cdecl decode(class cnst)" (?decode@@YAXVcnst@@@Z) referenced in function "bool __cdecl menu(class cnst)" (?menu@@YA_NVcnst@@@Z) C:\Users\toshiba\Documents\Visual Studio 2010\Projects\RSA\RSA\coder_decoder.obj
Search it in your code! Why do not you read the error message? It is clear enough.
I haven't faced such error before. I do not know what to search for. I would appreciate if you help me with this.

This is the code in coder_decoder.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<conio.h>

#include"fncs.h"

int main()
{
	long long p,q,e,phi;
	int N=0,flag;
	cout<<"Do you want to enclude english letters as using characters in cipher? (1 for yes,0 for no)";
	if(cin>>flag)
		N+=26;
	cout<<"Do you want to enclude numbers as using characters in cipher? (1 for yes,0 for no)";
	if(cin>>flag)
		N+=10;
	cout<<"Do you want to enclude the signs % , \" . ? ! space - _ ) ( @ / \\ : ; \' & = as using characters in cipher? (1 for yes,0 for no)";
	if(cin>>flag)
		N+=19;
	if(N==0)
		return 0;
	do
	{
		cout<<"Enter first prime number: ";
		cin>>p;
	}while(!isPrime(p));
	do
	{
		cout<<"Enter second prime number: ";
		cin>>q;
	}while(!isPrime(q));
	phi=(p-1)*(q-1);
	do
	{
		cout<<"Enter publi key: ";
		cin>>e;
	}while(gcd(e,phi)!=1);

	cnst c(p,q,e,N);

	while(menu(c))
		cout<<endl;

	getch();
	return 0;
}


and here's the cnst class
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef CNST_H
#define CNST_H

class cnst
{
public:
	const long long p;
	const long long q;
	const long long n;
	const long long phi;
	const int N;
	const int k;
	const long long e;
	const long long d;
	long long inverse(long long,long long);
	cnst(long long,long long,long long,int);
};

cnst::cnst(long long _p,long long _q,long long _e,int _N):
p(_p),
	q(_q),
	n(_p*_q),
	phi((_p-1)*(_q-1)),
	N(_N),
	k((int)(log((long double)n)/log((long double)N))),
	e(_e),
	d(inverse(phi,e))
{}

long long cnst::inverse(long long m,long long r)
{
	if(r==1)
		return r;
	int t;
	t=inverse(r,(m%r));
	return ((((r-t)*m)+1)/r)%phi;
}

#endif 


and the function menu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
bool menu(cnst o)
{
	char c;
	cout<<"What do you want to do?\npress \'e\' to encrypt or \'d\' to decrypt or \'q\' to quit: ";
	c=getch();
	cout<<c<<endl;
	switch(c)
	{
		case 'e':
			cout<<"Type your text,then press ESC to encrypt:"<<endl;
			code(o);
			break;
		case 'd':
			cout<<"Type your text,then press ESC to decrypt:"<<endl;
			decode(o);
			break;
		default:
			return false;
	}
	return true;
}


and I still haven't define the function decode. what is exactly unresolved here?
The error message says that in your module named coder_decoder in function bool menu(class cnst) there is a call to function void decode(class cnst) that was not defined.

Last edited on
thank you very much
Topic archived. No new replies allowed.