fork(1) download
  1.  
  2. namespace Foo {
  3.  
  4. class Deriv {};
  5. class Another {};
  6. Another operator* ( float x, const Deriv& d ) { return Another();}
  7. }
  8. namespace Bar {
  9. typedef Foo::Deriv MyDeriv;
  10. MyDeriv operator* (float x, const MyDeriv& d);
  11. }
  12.  
  13.  
  14. namespace Bar {
  15. void f1() {
  16. Bar::MyDeriv a;
  17. Bar::MyDeriv b = 3.f * a;
  18. }
  19. }
  20.  
  21. void f2() {
  22. Bar::MyDeriv a;
  23. Bar::MyDeriv b = 3.f * a;
  24.  
  25. }
  26.  
  27. int main() {
  28. // your code goes here
  29. return 0;
  30. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'void Bar::f1()':
prog.cpp:19:24: error: ambiguous overload for 'operator*' (operand types are 'float' and 'Bar::MyDeriv {aka Foo::Deriv}')
   Bar::MyDeriv b = 3.f * a;
                        ^
prog.cpp:12:10: note: candidate: Bar::MyDeriv Bar::operator*(float, const MyDeriv&)
  MyDeriv operator* (float x, const MyDeriv& d);
          ^
prog.cpp:8:10: note: candidate: Foo::Another Foo::operator*(float, const Foo::Deriv&)
  Another operator* ( float x, const Deriv& d ) { return Another();}
          ^
prog.cpp: In function 'void f2()':
prog.cpp:25:23: error: conversion from 'Foo::Another' to non-scalar type 'Bar::MyDeriv {aka Foo::Deriv}' requested
  Bar::MyDeriv b = 3.f * a;
                       ^
stdout
Standard output is empty