|
Post by Nicky Peter Hollyoake on Apr 9, 2008 20:25:20 GMT -5
How does define work then? Is abit like const? But it an do functions .... I kinda got it from this example.
#include <iostream.h> #define print cout << ""
main() { print"define test"; }
Thats one I made.
Nicky
|
|
|
Post by matthew on Apr 9, 2008 21:04:33 GMT -5
Are you writing a C program or a C++ program? If you're writing a C++ program, start using <iostream> & stop using <iostream.h>, as it's deprecated. You can use the #define statement in C++ but it's not really recommended that you use it a lot. #include <iostream>
#define print std::cout << ""
int main() { print"define test" << std::endl; // Wait for a keypress std::cin.get(); }
|
|
|
Post by Nicky Peter Hollyoake on Apr 9, 2008 21:12:58 GMT -5
Are you writing a C program or a C++ program? If you're writing a C++ program, start using <iostream> & stop using <iostream.h>, as it's deprecated. You can use the #define statement in C++ but it's not really recommended that you use it a lot. #include <iostream>
#define print std::cout << ""
int main() { print"define test" << std::endl; // Wait for a keypress std::cin.get(); }
I wouldn't mind learning both  . But yeah i'm actually trying to learn C++. I found a site noe that I can learn from, and its just aiemd at C++.  Nicky
|
|
|
Post by DJLinux on Apr 9, 2008 21:34:24 GMT -5
|
|
|
Post by Nicky Peter Hollyoake on Apr 11, 2008 13:16:01 GMT -5
Are you writing a C program or a C++ program? If you're writing a C++ program, start using <iostream> & stop using <iostream.h>, as it's deprecated. You can use the #define statement in C++ but it's not really recommended that you use it a lot. #include <iostream>
#define print std::cout << ""
int main() { print"define test" << std::endl; // Wait for a keypress std::cin.get(); }
#include <iostream.h>
int main(void) { cout << "Hello EDM/2" << endl; return 0; }
Matthew, I got that from a C++ tutorial, and it still is "<iostream.h>" is the tutorial wrong? Go to the link djlinux gave, and get the first tutorial, its got it there (to be honest though, I only had a quick scan through, so it might just be showing thats it s mistake, i'll give it a quick check before I send this message). Nope that what it definy says. Nicky
|
|
|
Post by Supermonkey on Apr 11, 2008 15:45:39 GMT -5
The tutorial is out of date (a lot are) <iosteam.h> is deprecated, what compiler are you using? Most give you a warning about that.
|
|
|
Post by Nicky Peter Hollyoake on Apr 11, 2008 15:56:59 GMT -5
Oooh! is that why I keep getting
warning This file includes at least one deprecated or antiquated header.
?
Whats the worse that could happen adding the extra ".h"?
|
|
|
Post by Supermonkey on Apr 11, 2008 15:59:12 GMT -5
I don't know specifics, I just know you shouldn't do it  .
|
|
|
Post by matthew on Apr 11, 2008 18:03:23 GMT -5
...Whats the worse that could happen adding the extra ".h"? Read this.
|
|