Thread: another way for "this" pointer

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    18

    another way for "this" pointer

    here is my code for a .cpp of a header file. My question is: is there another way to write this than using "this" pointer?

    Code:
    #include "Integer.h"
    
    Integer::Integer() //once Integer object is made it will be initialized to 0
    {
    	this->number=0;
    }
    
    Integer::Integer(int num) //once an Integer object is made it will be initialized to num
    {
    	this->number=num;
    }
    
    Integer::~Integer()
    {
    //nothing
    }
    
    int Integer::getInt()
    {
    	return this->number;
    }
    
    bool Integer::operator<(Integer i) // overload < operator
    {
    	if(this->number<i.number)
    		return true;
    	else
    		return false;
    }
    
    bool Integer::operator>(Integer i) //overload > operator
    {
    	if(this->number>i.number)
    		return true;
    	else
    		return false;
    }
    
    int Integer::operator++() //overload ++ operator
    {
    	return this->number++;
    }
    
    int Integer::operator--() //overload -- operator
    {
    	return this->number--;
    }
    just editited my code...this is the correct one
    Last edited by dukebdx12; 06-22-2008 at 12:05 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 10:10 AM
  2. Quick Pointer Question
    By gwarf420 in forum C Programming
    Replies: 15
    Last Post: 06-01-2008, 03:47 PM
  3. Parameter passing with pointer to pointer
    By notsure in forum C++ Programming
    Replies: 15
    Last Post: 08-12-2006, 07:12 AM
  4. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM