473,386 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

About Borland C++BuilderX's 2 questions

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::operator int()' and 'A::operator
int() const' in function A::operator 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.
Jul 19 '05 #1
2 3101
DarkSpy wrote:
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::operator int()' and 'A::operator
int() const' in function A::operator int() const at line 14
ok, i change it to:
operator int () const { return this->operator int(); }
that was ok.
It should however result in an endless loop, since the this object is
const within operator int() const, and so the const operator must be
called again.

why "operator std::string() const" was pass ? is it the ISO C++'s rule
or compiler's bug ?
I think both should pass, but both should result in an endless loop for
the const operator.
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


Is the above the exact code, exept from the '...'? Btw, it is usually
best to provide a minimal, but full program that is compilable except
from the error you observed. Do not just post code that never saw a
compiler.

Jul 19 '05 #2
Rolf Magnus <ra******@t-online.de> wrote in message news:<bn*************@news.t-online.com>...
DarkSpy wrote:
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::operator int()' and 'A::operator
int() const' in function A::operator int() const at line 14
ok, i change it to:
operator int () const { return this->operator int(); }
that was ok.


It should however result in an endless loop, since the this object is
const within operator int() const, and so the const operator must be
called again.

why "operator std::string() const" was pass ? is it the ISO C++'s rule
or compiler's bug ?


I think both should pass, but both should result in an endless loop for
the const operator.
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


Is the above the exact code, exept from the '...'? Btw, it is usually
best to provide a minimal, but full program that is compilable except
from the error you observed. Do not just post code that never saw a
compiler.


thank you Rolf Magnus.

the first question's point is:
i know the const object will call "operator int() const" loop and
loop, but my question is: why the *keyword* type were can not pass
except add "this->" operate code ? is this an ISO C++'s rule or CBX's
bug ?

the second question's point is:
the source code is exact code, the "..." is my omission code, not
important, my question is: why compiler tell me: the "void operate
delete" is multiple declaration ? the function:
void operate delete(void *);
and
void operate delete(void *, void *);
is not same functions, so......

is this an ISO C++'s rule or CBX's bug ?

thanx anyway.
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Steven O. | last post by:
First, sorry if by some chance I am not posting to the correct newsgroups, these seemed to be the most applicable to my question (see disclaimer at end of post for further comments....). Started...
1
by: J. W. McCall | last post by:
I know that this newsgroup is for pure C++ language questions only, but I wanted to ask where would be an appropriate place to post a question about this, as I can't find any that have any traffic....
24
by: serdar | last post by:
Hi. Does anybody say that what is better borland c++ or visual c++? Which compiler does have more help?
1
by: jeromeg | last post by:
Hi to all, I am working with Borland c++ 6 on XP I use a form which is not MODAL. In this form, users can type characters in a TEdit component. But when they type some characters which are...
1
by: BABONJI | last post by:
is there any crack for C++BuilderX 1.5 Mobile ?? thanks ---------------------------------------------- Posted with NewsLeecher v2.3 Beta 4 * Binary Usenet Leeching Made Easy *...
3
by: C# Learner | last post by:
1) When's C# 2.0 "coming out"? 2) Will all the .NET collection classes (e.g. ArrayList) be rewritten to use generics instead of object references? 3) This one's off-topic -- will Borland's C#...
3
by: Eli Hughes | last post by:
Hello All: Does anyone know where I could find a copy of Borland Turbo C version 3.0? I have piece of embedded hardware (Lantronix Xport) that can be reprogrammed but I need an old x86 compiler...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
45
by: mistral | last post by:
Does Visual C++ 2005 Express Edition produce small, compact C executables? Or there is another C compilers that do this better? m.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.