operator overloading

C

chetan

Hello All !

In c++, are basic data type int,char,long,..,etc. classes ? And if so,
How can i overload new and delete operators for this this objects ?

Thanks in advance !

Chetan
 
J

Joona I Palaste

chetan <[email protected]> scribbled the following
Hello All !
In c++, are basic data type int,char,long,..,etc. classes ? And if so,
How can i overload new and delete operators for this this objects ?
Thanks in advance !

What strange demon possessed you into thinking this has even the
slightest, most remote inkling to do with C?

--
/-- Joona Palaste ([email protected]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"You can pick your friends, you can pick your nose, but you can't pick your
relatives."
- MAD Magazine
 
J

jacob navia

chetan said:
Hello All !

In c++, are basic data type int,char,long,..,etc. classes ? And if so,
How can i overload new and delete operators for this this objects ?

Thanks in advance !

Chetan

The lcc-win32 C compiler accepts operator overloading.
The syntax is very similar to C++:

sometype operator +(sometype a,sometype b)

It is impossible to overload operators for the int, float type etc.

You can work around this by defining:

typedef struct {
int Thevalue;
} MyInt;

Then, you can write:

MyInt operator +(MyInt a,MyInt b) {... }
 
?

=?ISO-8859-15?Q?Juli=E1n?= Albo

chetan said:
In c++, are basic data type int,char,long,..,etc. classes ? And if so,
How can i overload new and delete operators for this this objects ?

Using Ruby instead of C++.
 
G

Gernot Frisch

Using Ruby instead of C++.

A language where everything works on all is bound to be slow...
-Gernot
 
K

Keith Thompson

jacob navia said:
The lcc-win32 C compiler accepts operator overloading.
The syntax is very similar to C++:
[snip]

How is this an answer to the OP's question?

The question was topical in one of the two newsgroups to which it was
posted. Your answer was topical in neither; lcc-win32 is not a C++
compiler, and its support for operator overloading is an extension to
standard C.
 
J

JKop

chetan posted:
Hello All !

In c++, are basic data type int,char,long,..,etc. classes ? And if so,
How can i overload new and delete operators for this this objects ?

Thanks in advance !

Chetan

No they're not classes. You cannot inherit from them.

To inherit from intrinsics types, I wrote a class called
IntrinsicClone which you used as so:

class Blah : public IntrinsicClone<double>
{

};


I never finished it though, found better ways to do things.

-JKop
 
D

Dan Pop

In said:
jacob navia said:
The lcc-win32 C compiler accepts operator overloading.
The syntax is very similar to C++:
[snip]

How is this an answer to the OP's question?

The question was topical in one of the two newsgroups to which it was
posted. Your answer was topical in neither; lcc-win32 is not a C++
compiler, and its support for operator overloading is an extension to
standard C.

Furthermore, last time I've checked, lcc-win32 was not conforming to any
C standard, even when invoked with standard conformance turned on. So,
any mention of lcc-win32 is off topic in c.l.c.

Dan
 
J

Joona I Palaste

Keith Thompson <[email protected]> scribbled the following
jacob navia said:
chetan said:
Hello All !
In c++, are basic data type int,char,long,..,etc. classes ? And if
so,
How can i overload new and delete operators for this this objects ?
Thanks in advance !
Chetan

The lcc-win32 C compiler accepts operator overloading.
The syntax is very similar to C++: [snip]

How is this an answer to the OP's question?
The question was topical in one of the two newsgroups to which it was
posted. Your answer was topical in neither; lcc-win32 is not a C++
compiler, and its support for operator overloading is an extension to
standard C.

I agree. I almost replied to Jacob Navia myself telling the same thing,
but then I thought that anyone who has written his own compiler should
know more about C than I do. But I still am annoyed by Jacob Navia
advertising his lcc-win32 everywhere he gets half the chance.
 
J

Jack Klein

In said:
jacob navia said:
chetan wrote:
Hello All !
In c++, are basic data type int,char,long,..,etc. classes ? And if
so,
How can i overload new and delete operators for this this objects ?
Thanks in advance !
Chetan

The lcc-win32 C compiler accepts operator overloading.
The syntax is very similar to C++:
[snip]

How is this an answer to the OP's question?

The question was topical in one of the two newsgroups to which it was
posted. Your answer was topical in neither; lcc-win32 is not a C++
compiler, and its support for operator overloading is an extension to
standard C.

Furthermore, last time I've checked, lcc-win32 was not conforming to any
C standard, even when invoked with standard conformance turned on. So,
any mention of lcc-win32 is off topic in c.l.c.

By your criterion, no compiler is topical here. Unless of course you
can name one that you can prove has 100% perfect conformance to any
version of the C standard. I've yet to see such a beast.
 
D

Dan Pop

In said:
In said:
chetan wrote:
Hello All !
In c++, are basic data type int,char,long,..,etc. classes ? And if
so,
How can i overload new and delete operators for this this objects ?
Thanks in advance !
Chetan

The lcc-win32 C compiler accepts operator overloading.
The syntax is very similar to C++:
[snip]

How is this an answer to the OP's question?

The question was topical in one of the two newsgroups to which it was
posted. Your answer was topical in neither; lcc-win32 is not a C++
compiler, and its support for operator overloading is an extension to
standard C.

Furthermore, last time I've checked, lcc-win32 was not conforming to any
C standard, even when invoked with standard conformance turned on. So,
any mention of lcc-win32 is off topic in c.l.c.

By your criterion, no compiler is topical here. Unless of course you
can name one that you can prove has 100% perfect conformance to any
version of the C standard. I've yet to see such a beast.

Anyone capable of engaging his brain should be able to tell the difference
between a compiler that fails to conform *by design* and one that fails to
conform due to the obscure bugs inherent in any program as complex as a
compiler.

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
anuragag27

Latest Threads

Top