0

I am a (re) beginner in C++. I tried if I could define a binary operator + but that only gave me a compiler error in g++. In C# they are independent of classes. In C++, like in Ruby, they are obviously not, such that they are unary.

Now in order for an internal grammar production representation I would need a binary operator + to create symbol lists, where the first element is a char* array (?) [that is, I don't know if the between of two \" is a literal in c++]

example 1:

list = "(" + elements + ")"

such that the binary operator + could create Terminal Symbols from the open/close parens

example 2:

std::vector<Symbol>* operator+ (char* string, Symbol sym) {
  return OpPlus(Terminal(string), sym);
}

Can I simulate binary operators in C++ ?

Yours

von Spotz

von spotz
  • 875
  • 7
  • 17

0 Answers0