fork(12) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class mystruct
  6. {
  7. private:
  8. int m_a;
  9. float m_b;
  10.  
  11. public:
  12. mystruct(int x, float y)
  13. {
  14. m_a = x;
  15. m_b = y;
  16. }
  17. friend ostream& operator << (ostream& os, const mystruct& m)
  18. {
  19. os << m.m_a <<" " << m.m_b << endl;
  20. return os ;
  21. }
  22.  
  23. };
  24.  
  25.  
  26. int main()
  27. {
  28.  
  29. mystruct m = mystruct(5,3.14);
  30.  
  31. cout << "my structure " << m << endl;
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
my structure 5 3.14