D
DarkSpy
Question 1:
class A
{
public:
operator int () { return 10; }
operator int () const { return operator int(); }
operator std::string() { return "abcd"; }
operator std::string() const { return operator std::string(); }
};
that was error with "operator int() const", message is:
"1.cpp": E2015 Ambiguity between 'A:perator int()' and 'A:perator
int() const' in function A:perator int() const at line 14
ok, i change it to:
operator int () const { return this->operator int(); }
that was ok.
why "operator std::string() const" was pass ? is it the ISO C++'s rule
or compiler's bug ?
Question 2:
class A
{
public:
void * operator new (size_t size) { ... }
void operator delete (void *p) { ... }
void * operator new (size_t size, void *p) { ... }
//placement new
void operator delete(void *p1, void *p2) { ... }
//placement delete
};
that whas error with two "operator delete functions"
with "void operator delete(void *p1, void *p2) { ... } "
1.cpp": E2238 Multiple declaration for 'A' at line 21
with "void operator delete (void *p) { ... }"
1.cpp": E2344 Earlier declaration of 'A' at line 10
when i deleted *ANY* one of the "operator delete" function, that was
ok.
is the void operator delete (void *p1, void *p2) do nothing with
placement operator new ?, because the C++BuilderX 's help document
wrote:
The second function (means: void operator delete(void *, void *); ) is
called by a placement delete expression corresponding to a new
expression of the form new(std::size_t). It does nothing.
thanks all anyway.
class A
{
public:
operator int () { return 10; }
operator int () const { return operator int(); }
operator std::string() { return "abcd"; }
operator std::string() const { return operator std::string(); }
};
that was error with "operator int() const", message is:
"1.cpp": E2015 Ambiguity between 'A:perator int()' and 'A:perator
int() const' in function A:perator int() const at line 14
ok, i change it to:
operator int () const { return this->operator int(); }
that was ok.
why "operator std::string() const" was pass ? is it the ISO C++'s rule
or compiler's bug ?
Question 2:
class A
{
public:
void * operator new (size_t size) { ... }
void operator delete (void *p) { ... }
void * operator new (size_t size, void *p) { ... }
//placement new
void operator delete(void *p1, void *p2) { ... }
//placement delete
};
that whas error with two "operator delete functions"
with "void operator delete(void *p1, void *p2) { ... } "
1.cpp": E2238 Multiple declaration for 'A' at line 21
with "void operator delete (void *p) { ... }"
1.cpp": E2344 Earlier declaration of 'A' at line 10
when i deleted *ANY* one of the "operator delete" function, that was
ok.
is the void operator delete (void *p1, void *p2) do nothing with
placement operator new ?, because the C++BuilderX 's help document
wrote:
The second function (means: void operator delete(void *, void *); ) is
called by a placement delete expression corresponding to a new
expression of the form new(std::size_t). It does nothing.
thanks all anyway.