Preprocessor

P

Protoman

Would you consider this to be destructive to programmers' sanity:

#define main Main
#define cout cerr
#define while(x) if(x)
#define class union
#define true 0
#define false 1

Comments welcome!!!
 
G

Guest

Protoman said:
Comments welcome!!!

I completely have no idea what is that for but if you like
comments here you have mine :)
> #define while(x) if(x)

Here you can not prevent programmer to use expression
which result does not make any sense in term of boolean.

Cheers
 
P

Protoman

#define while(x) if(x) means that the preprocessor will substitute
if(x) for any occurance of while(x).
 
G

Guest

Protoman said:
#define while(x) if(x) means that the preprocessor will substitute
if(x) for any occurance of while(x).

What for?
Do you want to do some test cases or what?
Cheers
 
P

Protoman

At my work, there's this person who upsets and annoys *everyone*, me,
my bosses, their bosses, the secretaries, absolutely everyone. He's a
grade A psycho. He's also *extremely* arrogant. He keeps trying to get
me and my other coworkers fired; he's even tried once to get my boss
and his boss fired. We're all going to get him with this. Do you know
any other ways of sabotaging his project (BTW, my boss has decided to
cancel the project; he's informed everyone but the man in question, [my
boss plans on firing him later this month] so it doesn't matter; he's
sanctioning this)?
 
P

puzzlecracker

Protoman said:
At my work, there's this person who upsets and annoys *everyone*, me,
my bosses, their bosses, the secretaries, absolutely everyone. He's a
grade A psycho. He's also *extremely* arrogant. He keeps trying to get
me and my other coworkers fired; he's even tried once to get my boss
and his boss fired. We're all going to get him with this. Do you know
any other ways of sabotaging his project (BTW, my boss has decided to
cancel the project; he's informed everyone but the man in question, [my
boss plans on firing him later this month] so it doesn't matter; he's
sanctioning this)?


Sounds more like a kindergarden. How old are you kid - 15 or 16?
 
B

BobR

Protoman wrote in message
At my work, there's this person who upsets and annoys *everyone*, me,
my bosses, their bosses, the secretaries, absolutely everyone. He's a
grade A psycho. He's also *extremely* arrogant. He keeps trying to get
me and my other coworkers fired; he's even tried once to get my boss
and his boss fired. We're all going to get him with this. Do you know
any other ways of sabotaging his project (BTW, my boss has decided to
cancel the project; he's informed everyone but the man in question, [my
boss plans on firing him later this month] so it doesn't matter; he's
sanctioning this)?

Write a program that will go through his code files and replace all
semi-colons(;) with colons:)). Remove all the 'virtual' from his base class
destructors.

Or, for the best way to 'get' the guy, BE NICE TO HIM!!! Extremely nice!
 
P

Protoman

BobR said:
Write a program that will go through his code files and replace all
semi-colons(;) with colons:)). Remove all the 'virtual' from his base class
destructors.

Or, for the best way to 'get' the guy, BE NICE TO HIM!!! Extremely nice!

For the first one, how do I do the virtual thing? I know how to do the
semicolon one, #define ; :. As for the second item please define "get".
That makes me uncomfortable. As for the guy, he's even more infuriating
then my PHB.
 
W

W Marsh

Protoman said:
For the first one, how do I do the virtual thing? I know how to do the
semicolon one, #define ; :. As for the second item please define "get".
That makes me uncomfortable. As for the guy, he's even more infuriating
then my PHB.

Sounds like you're jealous of him because he actually knows C++. I hope
you're not employed as a C++ guy there if you don't even understand
virtual destructors in abstract base classes.

I hope that your co-worker finds your messages and takes legal action
against you.
 
R

red floyd

puzzlecracker said:
Sounds more like a kindergarden. How old are you kid - 15 or 16?

Don't you know? Protoman's a JPL Rocket Scientist(TM), or so he claimed
at one point.
 
P

Protoman

BobR said:
Write a program that will go through his code files and replace all
semi-colons(;) with colons:)). Remove all the 'virtual' from his base class
destructors.

Or, for the best way to 'get' the guy, BE NICE TO HIM!!! Extremely nice!

Please define "get"; you're making me uncomfortable. And I forgot, what
exactly will removing virtuality accomplish? Make his objs destruct
improperly?
 
G

Guest

Protoman said:
At my work, there's this person who upsets and annoys *everyone*, me,
my bosses, their bosses, the secretaries, absolutely everyone. He's a
grade A psycho. He's also *extremely* arrogant. He keeps trying to get
me and my other coworkers fired; he's even tried once to get my boss
and his boss fired. We're all going to get him with this. Do you know
any other ways of sabotaging his project (BTW, my boss has decided to
cancel the project; he's informed everyone but the man in question, [my
boss plans on firing him later this month] so it doesn't matter; he's
sanctioning this)?

No more questions and comments from my side :)
Cheers
 
H

Howard

Protoman said:
At my work, there's this person who upsets and annoys *everyone*, me,
my bosses, their bosses, the secretaries, absolutely everyone. He's a
grade A psycho. He's also *extremely* arrogant. He keeps trying to get
me and my other coworkers fired; he's even tried once to get my boss
and his boss fired. We're all going to get him with this. Do you know
any other ways of sabotaging his project (BTW, my boss has decided to
cancel the project; he's informed everyone but the man in question, [my
boss plans on firing him later this month] so it doesn't matter; he's
sanctioning this)?

Fortunately for you that's all a bunch of bull (since, if I recall, you're
still in school). If the above were true, you'd have just provided public
documentation for the lawsuit he'd be sure to file.

Now go troll elsewhere.
 
B

BobR

Protoman wrote in message
Please define "get"; you're making me uncomfortable. And I forgot, what
exactly will removing virtuality accomplish? Make his objs destruct
improperly?

The "get" refers to pulling a prank, getting even, etc.

Try the following:

#include <iostream>
class Base1 { public:
~Base1(){ std::cout << "~Base1()\n";}
};

class Derived1 : public Base1 { public:
Derived1(){ std::cout << "Derived1()\n";
array = new char[1024 * 1024];
}
~Derived1(){ std::cout << "~Derived1()\n";
delete [] array;
}
private:
char *array;
};

int main() {
Base1* bp = new Derived1; // Upcast
delete bp;
return 0;
}

Run it, then change:

~Base1(){ std::cout << "~Base1()\n";}
to:
virtual ~Base1(){ std::cout << "~Base1()\n";}

....and run it again. Your findings?
 
P

Protoman

BobR said:
Protoman wrote in message
Please define "get"; you're making me uncomfortable. And I forgot, what
exactly will removing virtuality accomplish? Make his objs destruct
improperly?

The "get" refers to pulling a prank, getting even, etc.

Try the following:

#include <iostream>
class Base1 { public:
~Base1(){ std::cout << "~Base1()\n";}
};

class Derived1 : public Base1 { public:
Derived1(){ std::cout << "Derived1()\n";
array = new char[1024 * 1024];
}
~Derived1(){ std::cout << "~Derived1()\n";
delete [] array;
}
private:
char *array;
};

int main() {
Base1* bp = new Derived1; // Upcast
delete bp;
return 0;
}

Run it, then change:

~Base1(){ std::cout << "~Base1()\n";}
to:
virtual ~Base1(){ std::cout << "~Base1()\n";}

...and run it again. Your findings?

Derived's dtor never got called w/o virtuality... excellent... What
about:

#define DEBUG 1
#if DEBUG==1
//all header files and declarations/definitions, etc
#endif

Lets say someone resets debug to 0...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top