0

I made a bitset based string class and it has it's own getstring function. How can I make it so that whenever I call the object, It will call that function then return the result. I want it like the actual string class where you can just do std::cout << strobj; and it will just print the string. Currently whenever I call my bitstring object it requires a method. How do I make it like string's?

Thanks in advance

Cow Nation
  • 71
  • 9

1 Answers1

0

Its hard to answer this without seeing your code, but it sounds like you want to implement something like this

class Foo(){
  public:
  std::string GetString(){return myString;}
  std::string SetString(std::string str){myString = str;}

  friend std::ostream& operator<<(std::ostream& os, const Foo& foo)
  {
    return os << "My String Is:" << GetString() << "\n";
  }
  private:
  std::string myString;
};
HappyKeyboard
  • 145
  • 1
  • 7