|
-
Nov 25th, 2001, 09:40 PM
#1
Thread Starter
Registered User
#define,#ifdef,#else,#endif questions! book isn't very clear how they work..
Hello everyone,
I'm not new to programming in C++, i just bought a new book, a "software eingeering" one. and he's covering some things i must have skipped along the ways of reading bad online tutorials,
okay anyways here is the code
Code:
#define MT
#ifdef MT
#define NFILE 40
#else
#define NFILE 20
#end if
alright so called explanation which i don't get really:
This code is similiar to what you find in the header files; if hte symbol MT is defined, the limit for the number of files is 40; if we remove its definition form the source file, the lmit will be 20.
now what does it mean "if the symbol MT is defined" ?
can u give me an example when number one will be true? the number of files == 40, and one of the examples when the number of files == 20? or make up your own example that is eaiseer to understand
also i don't understand
Code:
#ifdef CPLUSPLUS
//whatever is needed when the program is wirtten in C++
#endif
or
Code:
#define __cplusplus
#ifdef __cplusplus
//whatever is needed when the program is written in C++
#end if
can u give me an code example that makes those statements run.
I understand how a simple one works like this:
Code:
#include <iostream>
#include <cmath>
#define Pi 3.1415926
using namespace std;
int main()
{
double x,y = 1;
double result;
cout <<"Welcome to the vb-world.com!" << endl;
x = y + 1;
result = pow(Pi,x);
cout <<"In that world, pi square is: " << result << endl;
cout <<"Have a nice day!" << endl;
return 0;
}
thansk for your time!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|