how to call function of one .cpp to another .cpp file

hi can any one please give the procedure how to call function of one .cpp into another .cpp file.

I want the changed values in that .cpp into another cpp file.

i used objects and pointer to call the member functions of class but i ddint get the values changed in one cpp into another.

by using pointer i am getting unhandled exception
Last edited on
1
2
//a.h
void foo();


1
2
3
4
5
6
//a.cpp
#include "a.h"

void foo(){
   //do things
}


1
2
3
4
5
6
//main.cpp
#include "a.h"

int main(){
   foo();
}


Make sure you're compiling both a.cpp and main.cpp (include them both in your project).

I don't understand what you're saying about pointers at all.
Hi hamsterman

Thanks for your reply.

Actually I declared 2 member functions in one class that is in A.cpp.

And i declared B.cpp and i want to use the member functions of class in A.cpp into class of B.ccp


Example:

A.cpp

Class test{
public:

int *a,*b;
assign(int &a,int &b);
};


B.h:
class Area{

int area;
int square();
int rectangle();
};

B.cpp

#include A.cpp
#include B.cpp

class Area::square(){

//here i want to call the assign function
}
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
//A.h
class test{
   public:

   int *a,*b;
   void assign(int &a,int &b);
};


//B.h:
class Area{
   int area;
   int square();
   int rectangle();
};

//B.cpp
#include "A.h"
#include "B.h"

int Area::square(){
   Test t;
   int a = 5, b;
   t.assign(b, a);
}
Last edited on
Topic archived. No new replies allowed.