Apr 15, 2009 at 11:30am UTC
So you just need to create a project with the IDE and they will be linked automatically.
Notice that when you #include a header the sourcecode in the header is placed by the preprocessor in the position of the #include line.
If you get Linker errors (errors starting with 'LNK') you will know that you may have problem with linked source files (eg: missing definitions)
Apr 15, 2009 at 6:00pm UTC
Thanks !
but can i use
#ifndef MYHEADER
#define MYHEADER
#endif
in my .cpp file ??
Last edited on Apr 15, 2009 at 6:01pm UTC
Apr 15, 2009 at 9:09pm UTC
Yes but is better having it in the header
Apr 15, 2009 at 11:19pm UTC
Thank you Buzzy !!
you have been a great help.
Buzzy you are a great buddy !!
Apr 16, 2009 at 1:04am UTC
Buzzy? lol After all the help he gave to you, you pronounce his name wrong!? OMG! ROLF :D
It's like "Thank's Jimmy!" .... Its Jonny!!
Anyways, you can have the main.cpp function prototypes in a .h file to increase readability and management.
Class interface and implementation (Function prototypes and definitions)
.h
.cpp
Main Prototypes Functions and definitions
.h
.cpp
driver, main or client
main.cpp
have fate!
Last edited on Apr 16, 2009 at 1:05am UTC
May 3, 2009 at 10:49am UTC
How can I with functions in header file modifed variables in .cpp file.
for example:
main.cpp:
1 2 3 4 5 6 7 8 9 10 11
# include <iostream>
using namespace std;
#include "funk.h"
int k=5; //global variabl
void main () {
s();
cout<<k;
}
header funk.h
1 2 3 4 5 6 7 8 9 10
#ifndef funk
#define funk
void s();
void s() {
k=555;
}
#endif
it notfy me an error:
Error 1 error C2065: 'k' : undeclared identifier c:\documents and setting....\stek.h
Error 2 error C2371: 'k' : redefinition; different basic types c:\documents and setting....\main.cpp 15
Is it posibile and how.
Can I do this with new .cpp file and how do it.
//I need to reduce space in my main.cpp but how can I do it by cuting code to other cpp.
and how can I add new .cpp file and with function in it modifed a gloabal variabla.
Last edited on May 3, 2009 at 11:52am UTC