S
Saxo
Hello,
I'm admittedly not very proficient in C++. This is why I post my question here for the expert can give me an accurate answer .
I have this piece of Scala code:
class A {
def foo() {
println("foo")
}
}
class B {
def bar() {
println("bar")
}
}
object Test
{
implicit def aToBWrapper(a: A) = {
println("before")
a.foo
println("after")
new B()
}
def main(args: Array[String])
{
val a = new A
a.bar
}
}
I guess it is not that hard to see what it does. When executed it prints:
before
foo
after
bar
My question is whether this could be done with in C++ as well using a conversion operator. The point is that no change is made to class A.
I could figure out myself. It would just take ages as I'm not familiar with C++.
Reagrds, Oliver
I'm admittedly not very proficient in C++. This is why I post my question here for the expert can give me an accurate answer .
I have this piece of Scala code:
class A {
def foo() {
println("foo")
}
}
class B {
def bar() {
println("bar")
}
}
object Test
{
implicit def aToBWrapper(a: A) = {
println("before")
a.foo
println("after")
new B()
}
def main(args: Array[String])
{
val a = new A
a.bar
}
}
I guess it is not that hard to see what it does. When executed it prints:
before
foo
after
bar
My question is whether this could be done with in C++ as well using a conversion operator. The point is that no change is made to class A.
I could figure out myself. It would just take ages as I'm not familiar with C++.
Reagrds, Oliver