Please tell me why the third line displays something in hexadecimal. Code:

#include <iostream> #include <stdio.h> using namespace std; class Something { private: string m_somenumber; public: Something(string somenumber) { m_somenumber = somenumber; } }; class Thing { private: int m_id; string m_name; Something* m_smth; public: Thing(int id, string name) { m_id = id; m_name = name; } void setSmth(Something* smth) { m_smth = smth; } void info() { cout << m_id << endl; cout << m_name << endl; cout << m_smth << endl; } }; int main() { Thing* thing = new Thing(1, "Name"); Something* smth1 = new Something("text"); thing->setSmth(smth1); thing->info(); return 0; } 

I get the output: - 1 - Name - 0x950fe0

  • 2
    Pointer is not dereferenced? - Alex Krass
  • Exactly. You print the value of the pointer, what do you order to display? - VladD

0