Hi everyone!
I'm trying to creat a class calling INT, which is equivalent to type int.
I think we must creat every operator for this class like: +, -, *, /, %, pow(x,y),...
I've never seen how does type int look like?
May someone give me a introduction to type int?
Is my idea correct about above operators?
Thanks in advanced!
svatstika 0 Newbie Poster
Recommended Answers
Jump to PostI think we must creat every operator for this class like: +, -, *, /, %, pow(x,y),...
Just two would suffice.
struct INT { INT() {} INT( int value ) : builtin_int(value) {} operator int& () { return builtin_int ; } operator int () const { return …
Jump to PostI mean why ++, --, +, - are working? every time we use ++ or -- or any other operator does it invoke the &() operator?
Yes. There is an implicit conversion from an
INT
to anint&
;void foo( INT& i ) { …
All 7 Replies
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
vijayan121 1,152 Posting Virtuoso
learningcpp 8 Newbie Poster
vijayan121 1,152 Posting Virtuoso
svatstika 0 Newbie Poster

embooglement
mrnutty 761 Senior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.