does overload operator-> a compile time action?
Posted
by Brent
on Stack Overflow
See other posts from Stack Overflow
or by Brent
Published on 2010-05-25T14:57:29Z
Indexed on
2010/05/25
15:01 UTC
Read the original article
Hit count: 157
c++
|operator-overloading
when I tried to compile the code:
struct S
{
void func2() {}
};
class O
{
public:
inline S* operator->() const;
private:
S* ses;
};
inline S* O::operator->() const
{
return ses;
}
int main()
{
O object;
object->func();
return 0;
}
there is a compile error reported:
D:\code>g++ operatorp.cpp -S -o operatorp.exe
operatorp.cpp: In function `int main()':
operatorp.cpp:27: error: 'struct S' has no member named 'func'
it seems that invoke the overloaded function of "operator->" is done during compile time? I'd add "-S" option for compile only.
© Stack Overflow or respective owner