Y
yvinogradov
I have a qustion about the attached piece of code. It compiles on gcc
version 3.4.1 (Cygwin special). The line in question has a single colon
instead of double. With double colon everything works as expected and
the base class implementation of foo() is called. With the single colon
the derived class implementation of foo() keeps calling itself
recursively. What does this single colon mean in this case?
Thanks.
-------------------------------------------------------------
#include <iostream>
class A {
public:
virtual void foo() {
std::cout << "A::foo()" << std::endl;
}
};
class B : public A {
public:
void foo() {
std::cout << "B::foo()" << std::endl;
A:foo(); // <----------------------------- Line in question
}
};
int main() {
B b;
b.foo();
return 0;
}
version 3.4.1 (Cygwin special). The line in question has a single colon
instead of double. With double colon everything works as expected and
the base class implementation of foo() is called. With the single colon
the derived class implementation of foo() keeps calling itself
recursively. What does this single colon mean in this case?
Thanks.
-------------------------------------------------------------
#include <iostream>
class A {
public:
virtual void foo() {
std::cout << "A::foo()" << std::endl;
}
};
class B : public A {
public:
void foo() {
std::cout << "B::foo()" << std::endl;
A:foo(); // <----------------------------- Line in question
}
};
int main() {
B b;
b.foo();
return 0;
}