undefined reference to

Below are the concerned files. The code is very simple and self-explanatory.

damwst.h :-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <deque>
#include <vector>
#include <queue>
#include <stdlib.h>
#include <iomanip>
#include "d_matrix.h"

#ifndef DAMWST_H
#define DAMWST_H

class Damwst
{
  public:
         void Initi( int n );
  private:
          vector < deque < int > > MsgQueue( int );
	  vector < int > SN( int, int ); 
	  matrix < int > SE( int, int, int);
 	  vector < int > FI( int );

};


#endif 

-----------------------------------------------------------------
damwst.cpp :-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <stdlib.h>
#include "damwst.h"

void Damwst::Initi( int n )
{
	MsgQueue( n ); 
	SN( n, 1 ); 
	SE( n, n, 1 ); 
 	FI( n );

} 

---------------------------------------------------------------
main.cpp
1
2
3
4
5
6
7
8
#include "damwst.h"

int main( int argc, char **argv ) 
{
  int nn = 5;
  Damwst dms;
  dms.Initi( nn );
}

----------------------------------------------------------------
errors given:

obj/Debug/damwst.o||In function `Damwst::Initi(int)':|
/damwst.cpp|58|undefined reference to `Damwst::MsgQueue(int)'|
/damwst.cpp|59|undefined reference to `Damwst::SN(int, int)'|
/damwst.cpp|60|undefined reference to `Damwst::SE(int, int, int)'|
/damwst.cpp|61|undefined reference to `Damwst::FI(int)'|



how do I remove this
undefined reference to
error??
Thanks in advance!!
The error is saying that the linker could not find the actual function definition for those functions.
I can't see them either - where are they written?
The below are not funtions,

MsgQueue( n );
SN( n, 1 );
SE( n, n, 1 );
FI( n );

They are actually (Vectors and Containers):
vector < deque < int > > MsgQueue( int );
vector < int > SN( int, int );
matrix < int > SE( int, int, int);
vector < int > FI( int );

But compiler sees them as funtions. Could you tell me the correct way to define vectors??!!
Eureka !! Eureka !! the changes required to my first post are as follows:
In damwst.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <deque>
#include <vector>
#include <queue>
#include <stdlib.h>
#include <iomanip>
#include "d_matrix.h"

#ifndef DAMWST_H
#define DAMWST_H

class Damwst
{
  public:
         void Initi( int n );
  private:
          vector < deque < int > > MsgQueue( int );
	  vector < int > SN( int, int ); 
	  matrix < int > SE( int, int, int);
 	  vector < int > FI( int );

};
#endif  

-------------------------------------------------------------------------------------------------------------
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <stdlib.h>
#include "damwst.h"

void Damwst::Initi( int n )
{
        MsgQueue( n );
	SN( n, 1 ); ---> SN.assign( n, 1 );
	SE( n, n, 1 ); ---> SE.resize( n, n, 1 ); 
	FI( n ); ---> FI.resize( n ); 
} 

---------------------------------------------------------------------------------------------------------
main.cpp
1
2
3
4
5
6
7
8
9
#include "damwst.h"

int main( int argc, char **argv ) 
{
  int nn = 5;
  Damwst dms;
  dms.Initi( nn );
}



Now the above code will work perfectly.
Topic archived. No new replies allowed.