HELP!!!! AGAIN AND AGAIN!!!!

We don't understand this errors:

C:\Users\RED1\projects\MiProyecto\Debug\main.o: In function `main':

C:/Users/RED1/projects/MiProyecto/main.cpp:10: undefined reference to `modulodeprueba()'

C:/Users/RED1/projects/MiProyecto/main.cpp:11: undefined reference to `mostrartriangulo()'

collect2.exe: error: ld returned 1 exit status

Can you explain them to us?

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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  #include<iostream>
using namespace std;

void tartaglia();
void modulodeprueba();
int factorial();
void mostrartriangulo();

int main () {
	modulodeprueba();
	mostrartriangulo();
	return 0;
}
const int N=29;
typedef int TMatriz [N][N];
void tartaglia (TMatriz A){
	int i;
	int j;
	for (j=0; j<=N; j++){
		for (i=0; i<=j; i++){
			if ((i=0) || (i==j)){
				A[i][j]=1;
			}
			else{
				A[i][j]=A[i][j-1]+A[i-1][j-1];
			}
		}
	}
}
void modulodeprueba(TMatriz A){
	int n;
	int m;
	int factorial(int x);
	n=8; 
	m=0;
    cout<<"El número es "<<factorial(n)/(factorial(m)*factorial(m-n))<<" y en la matriz está "<<A[n][m]<<endl;
	n=3; 
	m=3;
    cout<<"El número es "<<factorial(n)/(factorial(m)*factorial(m-n))<<" y en la matriz está "<<A[n][m]<<endl;
	n=2;
	m=1;
	cout<<"El número es "<<factorial(n)/(factorial(m)*factorial(m-n))<<" y en la matriz está "<<A[n][m]<<endl;
	n=5; 
	m=2;
	cout<<"El número es "<<factorial(n)/(factorial(m)*factorial(m-n))<<" y en la matriz está "<<A[n][m]<<endl;
}
int factorial (int n) {
	if (n==0)
		return 1;
	else 
		return n * factorial(n-1); 
}
void mostrartriangulo(TMatriz A){
	int M;
	cin>>M;
	int i;
	int j;
	for (j=0; j<=M; j++){
		for (i=0; i<=j; i++){
			cout<<A[i][j]<<" ";
		}
		cout<<endl;
	}
}
you declare:
void modulodeprueba();

but you're signature for that function when you come to implement it is:
void modulodeprueba(TMatriz A){

They need to match or else the compiler wont be happy.
Change line 5 to
void modulodeprueba(TMatriz A);

and the same for the other function it's moaning about as well.
It's still failing, can you give us another solution?
that IS the 'solution'.
What are the errors now? Post updated code please.
Same errors, it's probably my program, thanks for all.
I don't believe you :)
Did you change the function declarations like I advised in my first post?

edit:
this line:
typedef int TMatriz [N][N];

needs to go near the top. before your function declarations.

edit 2:
But first, seriously, I'd read this:
http://www.cplusplus.com/doc/tutorial/functions/

You need to make sure your declarations and impl signatures match AND call them passing in what the function expects. On your line 10 you write:
modulodeprueba();

but you need to pass in an object of type 'TMatriz' as this is what you've specified in your function implementation.

Last edited on
Topic archived. No new replies allowed.