std::cout endl = weird results....

Started by
5 comments, last by OpenGL_Guru 18 years, 9 months ago
hi all i had a problem last week with regarding printing out a string and some other stuff and getting weird results. i thought my string allocation maybe was being messed up but through trial and error i realized it was the endl that i was giving my problems. i have never had this happen before so i hope you could possibly help me out... whenever i invoke the endl such as a simple line of code: std::cout << endl; my output is: 004010EB wha????????? i am including <string> btw and like i said i havenever had this happen before. thanks for your time in advance :)
heh
Advertisement
Is there any chance endl is something else? You should be using std::endl.
Ra
This is strange indead. You dont have to include <string> but <iostream>. Are you using namespace std ?? Make sure endl is not declared as a pointer of some kind or variable.
nevermind i figured it out..why is it when i post on here half the time about 5 minutes later i figure it out while spending more than enough time before ive written the post?

anyway i have multiple classes together and inheritance going on. even though i included the <string> header file and the <iostream> header file in the .cpp file i didnt do the following line of code:

using namespace std;

even though i had done it with parent class it still was giving me this garbage in the child class.

ok ive got it fixed but why was i getting this output? just wanna know deeper of the problem.. thanks!
heh
well i was including <iostream> and <string> because of strcpy() that i needed.. but as i just wrote (as you were writing :D) i explained the problem but would like to know further why i was getting the output because of the line of code i didnt implement... thanks again.
heh
Most likely the endl was resolving to a symbol other than std::endl that had an implicit conversion to void *. If you use operator<< on a std::ostream with a void *, it prints the address of the pointer.
thanks mod.. like i said this has never happpened before and i have an unusual multiple inheritance going on such as

class a : protected class b, private class c
{...}

i simply forgot to add the using namespace std in one of my .cpp files ...so i guess i wont ever forget that again.. or at least when i get that error i will know what i need to change...
heh

This topic is closed to new replies.

Advertisement