Ceriwis  

Go Back   Ceriwis > HOBI > Komputer & Teknologi > Programming

Programming Share, tanya jawab, saling bantu antar programmer dengan berbagai macam bahasa pemrograman.

Reply
 
Thread Tools
  #1  
Old 11th November 2011
Braincode's Avatar
Braincode Braincode is offline
Ceriwis Addicted
 
Join Date: Nov 2011
Posts: 4,638
Rep Power: 21
Braincode mempunyai hidup yang Normal
Default yang Jago C++ Boleh Masuk Gan Plisssss[cendol inside]

Compiler Ane BORLAND Gan



<div style="margin:20px; margin-top:5px">
Spoiler for Help:


<div class="alt2" style="margin: 0px; padding: 6px; border: 1px inset;">
<div style="display: none;">
<div style="margin:20px; margin-top:5px">
Code:

#include
#include
#include
enum bool {false,true};
class Array
{ friend ostream &operator( istream &, Array & );
public:
Array( int = 10 );
Array( const Array & );
~Array()
{ delete [] ptr; }
int getSize() const;
const Array &operator=( const Array & );
bool operator==( const Array & ) const;
bool operator!=( const Array &right ) const
{ return ! ( *this == right ); // invokes Array:perator==
}
int &operator[]( int );
const int &operator[]( int ) const;
private:
int size;
int *ptr;
};
Array::Array( int arraySize )
{
size = ( arraySize > 0 ? arraySize : 10 );
ptr = new int[ size ];
for ( int i = 0; i < size; i++ )
ptr[ i ] = 0;
}
Array::Array( const Array &arrayToCopy ) : size( arrayToCopy.size )
{ ptr = new int[ size ];
for ( int i = 0; i < size; i++ )
ptr[ i ] = arrayToCopy.ptr[ i ];
}

int Array::getSize() const
{ return size; }
const Array &Array:perator=( const Array &right )
{ if ( &right != this )
{ if ( size != right.size )
{ delete [] ptr;
size = right.size;
ptr = new int[ size ];
}
for ( int i = 0; i < size; i++ )
ptr[ i ] = right.ptr[ i ];
}
return *this;
}
bool Array:perator==( const Array &right ) const
{ if ( size != right.size )
return false;
for ( int i = 0; i < size; i++ )
if ( ptr[ i ] != right.ptr[ i ] )
return false;
return true;
}
int &Array:perator[]( int subscript )
{ if ( subscript < 0 || subscript >= size )
{ cout
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Terkait
Thread Thread Starter Forum Replies Last Post
JUAL Yang Jago sotosop masuk [Cendol Inside] DagingAyam Gratisan 0 5th November 2012 02:52 PM
[HELP]Yang Jago Sotosop Masuk Cendol Inside bostempe Lounge 0 27th May 2012 06:20 PM
2x2=5, bagaimana mungkin (yang jago matematika masuk sini!!) CENDOL INSIDE ps3black Lounge 0 27th May 2012 05:31 PM

 


All times are GMT +7. The time now is 11:38 AM.