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 


Here is my noob c++ polymorphism test

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

Joined: 21 Mar 2006
Posts: 172
Location: Knee deep in a c++ book

PostPosted: Tue Nov 13, 2007 10:52 am    Post subject: Here is my noob c++ polymorphism test Reply with quote

Code:
#include <iostream>
using namespace std;
class Animal
{
      public:
              int getage() {return lifeline;}
              void setage(int age){lifeline = age;}
      private:
              int lifeline;
                   
};

class Bird : virtual public Animal
{
      public:
             double getHeight() {return itsHeight;}
             double setHeight(double Height) {itsHeight = Height;}
      private:
              double itsHeight;
             
};

int programquit()
{
    cout << "good bye";
    return EXIT_SUCCESS;
}

int main()
{
    Bird *pbird = new Bird;
    double Height;
    double quit;
    int Age;
    while(true)
   {
           cout << "Enter the bird's height in inches"<< endl;
           cin >> Height;
           if(Height<0)
           {
           programquit();
           break;
           }
           pbird->setHeight(Height);
           cout << "Enter the bird's age in years"<< endl;
           cin >> Age;
           if(Age<0)
           {
           programquit();
           break;
           }
           pbird->setage(Age);
           cout << "The bird is " << pbird->getHeight() << " inches tall\n";
           cout << "It's age is " << pbird->getage() << " years old\n";
           cout << "Enter any number under 10 to quit\n";
           cin >> quit;
           if(quit<0||quit<10)
           {
           programquit();
           break;
           }
   }
   delete pbird;
   return EXIT_SUCCESS;
}


Ok can anyone tell me what I have done wrong. I know i did'nt prototype. I got lazy and just used "using namespace std;". Instead of std::cout and so on.

_________________

Earthbound = 31337
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Tue Nov 13, 2007 5:05 pm    Post subject: Reply with quote

I am disappointed. I came in here looking for a polymorphic code example when all it is is polymorphic classes. Sad
Back to top
View user's profile Send private message
Losplagos
Expert Cheater
Reputation: 0

Joined: 21 Mar 2006
Posts: 172
Location: Knee deep in a c++ book

PostPosted: Tue Nov 13, 2007 6:08 pm    Post subject: Reply with quote

Flyte wrote:
I am disappointed. I came in here looking for a polymorphic code example when all it is is polymorphic classes. Sad


I am sorry about that i said noob polymorphism.

_________________

Earthbound = 31337
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Tue Nov 13, 2007 6:08 pm    Post subject: Reply with quote

Flyte wrote:
I am disappointed. I came in here looking for a polymorphic code example when all it is is polymorphic classes. Sad


Probably gunna regret posting this link on this site but meh..
-Link removed for good reasons.-

Theres a good amount of virus engines on that site that also include some polymorphic code examples. Should be able to find something to fancy your taste.

_________________
- Retired.


Last edited by atom0s on Tue Nov 13, 2007 6:24 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Tue Nov 13, 2007 6:21 pm    Post subject: Reply with quote

Don't worry Wiccaan, I already know how to achieve that. Wink I was just hoping that somebody would post something half useful as the vast majority of threads are not (polymorphism is a great way to undetect a small program from memory scans, hint: Game Guard). But thanks for your consideration anyways. Smile

About the link itself: Most people here will not understand how it works, but you can remove it if you feel you have to.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Tue Nov 13, 2007 6:24 pm    Post subject: Reply with quote

Flyte wrote:
Don't worry Wiccaan, I already know how to achieve that. Wink I was just hoping that somebody would post something half useful as the vast majority of threads are not (polymorphism is a great way to undetect a small program from memory scans, hint: Game Guard). But thanks for your consideration anyways. Smile

About the link itself: Most people here will not understand how it works, but you can remove it if you feel you have to.


Heh, from what I've seen on these forums, anything is bound to show up on the forums after linking to open source projects. Wink Anyway, yea link removed for good-measure.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
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