Put 1.cpp and 2.cpp in the same directory, for example:
The 1.cpp code is as follows
#include <iostream>
int main ()
{
void Changefunction (int* input, int n);
void Printdata (int* input, int n);
int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
Printdata (A, 10);
Changefunction (A, 10);
Printdata (A, 10);
return 0;
}
The 2.cpp code is as follows
#include <iostream>
void Changefunction (int* input, int n)
{
for (int i = 0; i < n; i++)
{
Input[i] + = 10;
}
}
void Printdata (int* input, int n)
{
Std::cout << "=============================" << Std::endl;
for (int i = 0; i < n; i++)
{
Std::cout << Input[i] << "";
}
Std::cout << Std::endl;
Std::cout << "-----------------------------" << Std::endl;
}
Output Result:
=============================
1 2 3 4 5 6 7 8 9 10
----------------------------------------------
=============================
11 12 13 14 15 16 17 18 19 20
----------------------------------------------
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C + + inside is a header file, the standard practice is: The header file inside the function declaration, the CPP function is implemented specifically. According to your description should be able to use a. h header file to put all the functions of the Declaration, and then put a function in 1.cpp, 2.cpp put another function, we put 1.cpp as the entry of the program as a data source, where the function called 2.cpp, this function returns the result of the calculation. Note that all two CPP includ header files
C + + A project has two CPP files, want to invoke another CPP file in a CPP file calculation results, how to achieve AH?