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 


[Help] C++ Object Oriented Programming

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
treepig
How do I cheat?
Reputation: 0

Joined: 21 Jul 2011
Posts: 1

PostPosted: Thu Jul 21, 2011 3:23 am    Post subject: [Help] C++ Object Oriented Programming Reply with quote

I am not sure if I am proceeding on my project correctly. I am not asking for someone to do my homework. I just need some pointers and hints to proceed. Thank You.

Code:

#include <iostream>
#include <string>
using namespace std;
class Bicycle {
   
    // Instance field
private:
   string ownerName;
    int licenseNumber;
   
    // Default Constructor
public:
   Bicycle () {}
   
    // Other Constructor
    Bicycle( string name, int license ) {
       ownerName = name;
      licenseNumber = license;
    }
   
    // Returns the name of this bicycle's owner
    string getOwnerName( ) {
        return ownerName;
    }
   
    // Assigns the name of this bicycle's owner
    void setOwnerName( string name ) {
        ownerName = name;
    }   
   
    // Returns the license number of this bicycle
    int getLicenseNumber( ) {
        return licenseNumber;
    }
   
    // Assigns the license number of this bicycle
    void setLicenseNumber( int license ) {
        licenseNumber = license;
    }
};

int main ()
{
   // Create 2 Bicycle references
    Bicycle b1, b2("chicken", 23424);
   
   // Create 2 String references for owners' namesq
    string s1;
    string s2;
   
   // Create 2 integers for license numbers
    int num1;
    int num2;
   
   // Bicycle 1 is owned by Kenny McCormick, license number 12345
   // Use the your full name and a license number for Bicycle 2
   // This data must be stored in the above String and integer variables.
   
   // Create the first Bicycle object with the default Bicycle constructor
   
 
   // Set the owner's name and license number with set methods using
   // the variables you created as arguments
   
    b1.setOwnerName("Kenny McCormick");
    s1 = b1.getOwnerName();
   
    b1.setLicenseNumber(12345);
    num1 = b1.getLicenseNumber();
   
    s2 = b2.getOwnerName();
   
    num2 = b2.getLicenseNumber();
   
   
   // Create a second Bicycle object with the other Bicycle constructor
   // Use the variables you created as arguments
       
    // Output each owner's name and license number in cout statements
   // using the objects and the get methods.  For example: bike1.getOwnerName()
    cout << "Bicycle #1" << endl;
    cout << "Name : " << s1 << endl;
    cout << "License Number : " << num1 << endl;
   
    cout << "Bicycle #2" << endl;
    cout << "Name : " << s2 << endl;
    cout << "License Number : " << num2 << endl;

   
    return 1;
}
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