S
ssylee
For example, I have two .cpp files. One called a.cpp and b.cpp.
a.cpp contains the function definition for the following functions:
void a_fun1(...)
{
....
}
void a_fun2(...)
{
....
}
and b.cpp contains function definition for the following functions:
void b_func1(...)
{
....
}
void b_func2(...)
{
....
}
Let's say in the implementation of b_func1() function, I need to use a
function in a.cpp (e.g. a_fun2() function). I know that I can expose
the functions in a.cpp that I want to the public in the project by
declaring the functions in the header file. I also know that I can
declare an extern function in b.cpp before calling that particular
function. What are the pros and cons of each? It would be great to
hear about some second opinions. The only ones that I can think of are
exposing the functions via the header file would make the project
easier to manage, while I would get rid of extra header files if I
declare the functions to be extern before they are used.
a.cpp contains the function definition for the following functions:
void a_fun1(...)
{
....
}
void a_fun2(...)
{
....
}
and b.cpp contains function definition for the following functions:
void b_func1(...)
{
....
}
void b_func2(...)
{
....
}
Let's say in the implementation of b_func1() function, I need to use a
function in a.cpp (e.g. a_fun2() function). I know that I can expose
the functions in a.cpp that I want to the public in the project by
declaring the functions in the header file. I also know that I can
declare an extern function in b.cpp before calling that particular
function. What are the pros and cons of each? It would be great to
hear about some second opinions. The only ones that I can think of are
exposing the functions via the header file would make the project
easier to manage, while I would get rid of extra header files if I
declare the functions to be extern before they are used.