On Suday the 11th of February, 2007 -after 3 and a half years on InvisionFree, we have moved! This old board remains as a read only archive of years past, and registration has been disabled here. All new and current members should register at http://www.cpplc.net/forum .
| · Portal |
Help
Search
Members
Calendar
|
| Welcome Guest ( Log In | Register ) | Resend Validation Email |
| Welcome to C++ Learning Community. We hope you enjoy your visit. You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you're already a member please log in to your account to access all of our features: |
![]() ![]() ![]() |
| Mephisto |
Posted: Feb 8 2007, 08:06 PM
|
||||||||||
|
N00b!!! Group: Members Posts: 5 Member No.: 2,428 Joined: 31-January 07 |
Allright, as most of you might know, you can define an operator to work with a Data type within a definition. This means using something like this:
Now this is great in most programs, you pass the operator function by falue, and when the operator is called, it works great. But in Devc++, there is a problem. If you, say..
Then in Devc++, after compiled, and you run, you are going to get an error. Now, this code will work perfect in most C++ programming environments. But in Devc++, there seems to be a problem. I'm not exactly sure why, and if anyone could help explain why this happens, I'll be greatful for the knowledge. There is only one solution...You must pass the operator function by reference... This is bad programming practice, and in fact, you will get a warning, telling you that you are passing the operator by reference. It will look something like this:
This presents yet another problem, though. If you use coding like what is below, the << operator will erase what is in f1 because of memory stack, and you will get some wierd numbers out of the operation.
Instead you must define an Extra Variable.
I hope this helps someone. I've been trying to debug a program with this problem for 3 days. Finally I gave out and asked my instructor. All this is the result and my understanding of what he told me from memory. If anything you see is wrong, let me know, because this is how I understood the problem with Devc++. |
||||||||||
![]() |
![]() ![]() ![]() |