Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


custom operator

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
NINTENDO
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Nov 2007
Posts: 1371

PostPosted: Tue Apr 21, 2009 2:15 am    Post subject: custom operator Reply with quote

Hey there.
I tried to overload an operator but it freaked out on me so how do I create a new one?

_________________
Intel over amd yes.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Zerith
Master Cheater
Reputation: 1

Joined: 07 Oct 2007
Posts: 468

PostPosted: Tue Apr 21, 2009 3:04 am    Post subject: Reply with quote

you can't create a fully new operator, though you can overload one only for classes,enums etc. not native types.
Back to top
View user's profile Send private message MSN Messenger
NINTENDO
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Nov 2007
Posts: 1371

PostPosted: Tue Apr 21, 2009 3:44 am    Post subject: Reply with quote

Zerith wrote:
you can't create a fully new operator, though you can overload one only for classes,enums etc. not native types.

the operator i want to overload aint overloadable so that's not an option.

_________________
Intel over amd yes.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Zerith
Master Cheater
Reputation: 1

Joined: 07 Oct 2007
Posts: 468

PostPosted: Tue Apr 21, 2009 4:25 am    Post subject: Reply with quote

what do you mean isn't overloadable? everything is overloadable.
Back to top
View user's profile Send private message MSN Messenger
NINTENDO
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Nov 2007
Posts: 1371

PostPosted: Tue Apr 21, 2009 7:16 am    Post subject: Reply with quote

Zerith wrote:
what do you mean isn't overloadable? everything is overloadable.

Oh, great. Is that why visual studio told me that it isn't overloadable? I'll try again.
Edit :
What is this! Now i get other errors.

_________________
Intel over amd yes.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Zerith
Master Cheater
Reputation: 1

Joined: 07 Oct 2007
Posts: 468

PostPosted: Tue Apr 21, 2009 8:42 am    Post subject: Reply with quote

wallantia wrote:
Zerith wrote:
what do you mean isn't overloadable? everything is overloadable.

Oh, great. Is that why visual studio told me that it isn't overloadable? I'll try again.
Edit :
What is this! Now i get other errors.


Posting your code and errors will assist us in helping you.
Back to top
View user's profile Send private message MSN Messenger
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Tue Apr 21, 2009 12:16 pm    Post subject: Reply with quote

Zerith wrote:
what do you mean isn't overloadable? everything is overloadable.


Not everything. Here is a list.
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Tue Apr 21, 2009 12:28 pm    Post subject: Reply with quote

personally I hate C++ because of the overloading its making programming not what it should be.. thats why C is the best language to program in my opinion.

Anyways he is a example of me overloading the () operator

Code:


struct Stride
{
   int stride;
   int NumVertices;
   int primCount;
   //int startIndex;

   bool operator()(Stride& strStart, strStride& End)
    {
          return strStart.stride < strEnd.stride;
    }
};


vector<Stride> strides;

now when you call Stride() in the sort method which uses vectors it will sort it in increasing order because of the < check

sort(strides.begin(), strides.end(), Stride());

_________________
Hacks I made for kongregate.
Kongregate Universal Badge Hack: http://forum.cheatengine.org/viewtopic.php?p=4129411
Kongreate Auto Rating/Voter hack: http://forum.cheatengine.org/viewtopic.php?t=263576
Took a test lol
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Wed Apr 22, 2009 2:09 am    Post subject: Reply with quote

pkedpker wrote:
Code:
struct Stride
{
...
}
Structs are not allowed to have member functions, only classes. C++ might allow member functions in structs, but I'm not sure, just use classes and the case is solved.

pkedpker wrote:
now when you call Stride() in the sort method which uses vectors it will sort it in increasing order because of the < check
Make sure you don't get confused between your overloaded operator and the constructor :) You should be doing
Code:
Stride s;
s();
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites