Anonymous
I know that it will show error
klimi
yes exactly
Anonymous
But, the thing is why twice?
klimi
g++ main.cpp foop.cpp foop.h
klimi
This is the build command
Anonymous
I'm compiling using g++ main.cpp
Anonymous
with #include "foop.cpp" in main
klimi
so it goes MAIN: include foop.cpp into the source compile to obj FOOP: compile to obj LINK: error i have foo in main and in foop
Anonymous
Is that going to give error?
I_Interface
I just replaced #include "foop.cpp" with the foo() definition. That's it
u must replace #include "foo.cpp" with "foo.h" if u want it works
Dima
klimi
[kurimi@KlimiStation tg]$ g++ main.cpp [kurimi@KlimiStation tg]$ ./a.out 42 43
Anonymous
That's what I was asking
Anonymous
So
Anonymous
this
Anonymous
I mean to say is that: #include <iostream> #include "foop.cpp" int main(int argc, char *argv[]) { int x=42; std::cout << x <<std::endl; std::cout << foo(x) << std::endl; return 0; }
Anonymous
won't give error on
Anonymous
g++ main.cpp
Anonymous
Right?
klimi
but dont do that
Anonymous
g++ main.cpp foop.cpp foop.h
What do you say to this?
Anonymous
Compiling many files?
Anonymous
or something else?
klimi
its what devcpp does
Anonymous
I mean what is the correct way to describe what you wrote
klimi
dont include cpp but include headers?
Anonymous
What is the correct way to describe this: g++ main.cpp foop.cpp foop.h
I_Interface
Anonymous
dont include cpp but include headers?
But, that's only when you are compiling just main.cpp
Anonymous
What do we say to that?
Anonymous
compiling many files? or something else?
klimi
just include headers, the compiler will take care of the rest
klimi
from cpp code it creates .o (obj files) and then it build the program with linker
Anonymous
just include headers, the compiler will take care of the rest
But, it worked when we do g++ main.cpp in the above case.
klimi
yes
klimi
because you told do do only one o
klimi
just one obj file, nothing to link (almost)
Anonymous
So, it compiled only main.cpp
Anonymous
?
Anonymous
and what happened to foop.cpp ?
Anonymous
We didn't compile foop.cpp
Anonymous
I mean I didn't compile foop.cpp
Anonymous
for main.cpp to run perfectly
klimi
because you included it
Anonymous
and in what case would we need to do
Anonymous
g++ main.cpp foop.cpp foop.h
Anonymous
?
Anonymous
I_Interface
g++ main.cpp foop.cpp foop.h
never include cpp file into another cpp file that is the rule
Anonymous
Any church management system?????
Anonymous
never include cpp file into another cpp file that is the rule
Well I understand that. and I won't do it.
I_Interface
Good
Anonymous
But, I'm asking is
Anonymous
and in what case would we need to do
Anonymous
g++ main.cpp foop.cpp foop.h
I_Interface
Anonymous
When?
Anonymous
Why did Klimi write this g++ main.cpp foop.cpp foop.h
klimi
i g
Anonymous
oh gosh
Anonymous
I mean what does that do?
klimi
[kurimi@KlimiStation tg]$ g++ main.cpp foop.cpp
Anonymous
I've never written g++ main.cpp foop.cpp foop.h
klimi
yes you are right i dont need .h
klimi
gtg
Anonymous
yes you are right i dont need .h
So, when we would write g++ main.cpp foop.cpp
Anonymous
I've never written 2 cpp files in a single g++ command.
Anonymous
That's why I'm asking
Anonymous
whatcha need
Do u have it