This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Problem with "<<" operator


Hi,
I have a little problem with a class and the << operator:

// MyClass.h
class MyClass
{
 .....
public:
  MyClass& operator<<(bool b);
};

extern "C++"
{
  extern MyClass& dummy(MyClass &myclass);
}



// MyClass.cpp
MyClass& operator<<(bool b)
{
  // Do something
  return(*this);
}

MyClass& dummy(MyClass &myclass)
{
  myclass.AFunction();
  return(myclass);
}



// Main.cpp
int main()
{
  MyClass mc;

  mc<<dummy;
}


The problem is that when I execute the code, the compiler generate a call to
the operator<<(bool) and doesn't execute the code in the dummy function.
-- 


Ir. Pascal Francq
Researcher
Université Libre de Bruxelles
Faculty of Applied Mechanics
Avenue F.D. Roosevelt, 50
CP 165/41
B-1050 Brussels
BELGIUM
Tel. +32-2-650 47 65
Fax +32-2-650 27 10

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]