# c++ language

This topic is 4867 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

when you program in c++.net do you use c++ language or does c++.net use the net language?

The first one.

##### Share on other sites
IIRC, which I probably don't, you can compile for either .net or for straight C++. Compiling for .net means you need the .net libraries inorder to run your program, but in exchange you get extra functionality.

##### Share on other sites
this will compile in .net, but not in regular C++

for (int i=0; i<5; i++){}for (int i=0; i<5; i++){}

in regular, the variable i is not destroyed so you get errors when redefining it. I really hated that too.

##### Share on other sites
regular meaning: ANSI C++, VC++ 6.0, or VC++ 7.1?

##### Share on other sites
6.0 for sure, I don't know about the others.. never used them.

##### Share on other sites
Quote:
 Original post by Lee_this will compile in .net, but not in regular C++*** Source Snippet Removed ***in regular, the variable i is not destroyed so you get errors when redefining it. I really hated that too.

That is not "regular" C++, that is the bastardized version of C++ that visual studio 6.0 uses. As it was written in 1997 before the standard was finalized (1998). If you are still using 6.0, upgrade. You can get the CLI compiler toolkit free from microsoft, or get a better IDE entirely for about \$100. If you wait a while though, 2k5 will be released, and that's even better.

##### Share on other sites
Quote:
 Original post by Lee_this will compile in .net, but not in regular C++*** Source Snippet Removed ***in regular, the variable i is not destroyed so you get errors when redefining it. I really hated that too.
That will compile in most c++ compilers, it's just vc 6.0 that sucks.

##### Share on other sites
Quote:
 Original post by Lee_6.0 for sure, I don't know about the others.. never used them.

This one has benn corercted in VC.NET versions.

To get rid of this problem using VC6, just add

#define for            if (1) for

HTH

##### Share on other sites
well gosh [oh], wish I had known that a few months ago.

##### Share on other sites
Quote:
 Original post by Emmanuel DelogetTo get rid of this problem using VC6, just add#define for if (1) for in your stdafx.h header.

Quick question; what should the following program output, and what does it output with that for-hack defined?
int main(int, char **){	const int foo = 1;	if(foo == 0)		for(int i = 0; i < 10; ++i) cout << "foo" << endl;	else		cout << "huh?" << endl;}

Not a problem if you always surround if statements with {}'s, even for single-liners, but it's still a possible error source. Just imagine trying debugging an error like this!

A better for-hack would be this.
#define for            if(0); else for

I have not yet seen a situation where the resulting behaviour is different from what it should be. If anyone knows one, feel free to say so.

But of course, the best solution is to get a better compiler.

##### Share on other sites

This topic is 4867 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628730
• Total Posts
2984427

• 25
• 11
• 10
• 16
• 14