Yes I found that out in the meantime. Was just confused by the strange overload.
Sorry.
Kurt
Yes I found that out in the meantime. Was just confused by the strange overload.
Sorry.
Kurt
I am learning. So whatever I'll do now would be strange.
Don't mix learning two things at once. If you want to learn pointers, learn pointers. (But learn both how and when to use them. The learning effect of using new Java-style is just about nil.) If you want to learn operator overloading, learn operator overloading. Don't mix the two. It leads to strange results, as you've discovered.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
I am actually a very experienced PHP programmer that's why I am much familiar with new and -> operator
And -> can be used with pointer only.
And that's why I've a tendency to use new.else it looks like Function not like object to myself.
And what can I do if new operator involves Pointer.
Last edited by noobcpp; 06-30-2007 at 06:06 AM.
In this case you don't need to learn but unlearn about pointers
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
OK.
Thanks Pointer is Cool then.
But I still didn't Understand
Originally Posted by anon
Last edited by noobcpp; 06-30-2007 at 07:12 AM.
In PHP its too hard to make a parser.It has only refference although I've atlast Made it.
Its a HTML / XML / wml / ...ML Parser Compleately made by PHP (95 % made still now)
With it you can Parse XMl with SQL like Statement. and Its very fast It takes just 0.02 MICROsecond to parse a Standerd XML File
Now I wanna Convert it to C and C++ also
Thats why I found pointer and refference in C++ Very Cool.
PHP keeps Pointer Internally But dont lets us to use it like C++ or C.
About why it's wrong to return a pointer to object from overloaded = operator.
With built-in types it is normal to write the following to set both a and b to c.
If you return a pointer from your operator overload, you couldn't use this syntax any more. Instead you'll need to dereference the returned pointer.Code:int a, b, c = 42; a = b = c; // means: a = (b = c);
If you added more assignments to the chain, it would look even worse.Code:MyClass a, b, c; a = *(b = c);
That's why this overload should return a reference instead.
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
Oh! I see.
C++ is not PHP. If you learn a new language, you will have to learn the best practices for this language, else your code will be bad. For C++, using pointers only where necessary is a best practice.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
I think you are right.