Uroci.net - !
Adobe Photoshop Adobe Illustrator Adobe Flash Adobe Fireworks DreamWeaver CSS HTML Corel Draw Image Ready PHP SEO CMS Microsoft Windows Microsoft Word Microsoft Excel PowerPoint Microsoft Access Microsoft Publisher Linux Visual basic JavaScript Ajax 3ds Max Maya 3D C++
C++
Sound Forge Gimp SWiSH

C++ .7 ( )

C++ » C++
fix3d   :    : 6961





. , tbl tbl2 16 String:

const int size = 16;
String tbl[ size ];
String *tbl2 = new String[size];

, . . :

while ( cin >> tbl[ i ] )
tbl[i].display();

, . , . , ; , , .

Stirng ar1[] = { "phoenix", "crane" };
String ar2[3] = { String(), String(1024),String("string")};
String ar3[2] = { 1024, String( 512 );
};
Screen as[] = { Screen(24, 80,#) };

, (.. ) . . , . .

tbl2 delete . ,

delete tbl2;

String tlb2. delete , tbl2 String, . delete , tbl2 . :

delete [ size ] tbl2;

String tbl2.



String, Word char* String, .

class Word {
public:
Word();
Word( char*, int = 0 );
Word( String&, int = 0 );

private:
int occurs;
String name;
};

Word - String. :

1. ? , ?
2. ?

. , . , , , . ( ).

// first String::String( char * )
// then Word::Word( char * ) Word flower( "iris" );

- , /, . ,

Word::Word( char *s, int cnt ) : name( s ) { occurs = cnt; }

. . ; . name s, String. . , occurs cnt:

Word::Word( char *s, int cnt ) : name( s ), occurs( cnt ) {}

- . . ,

class Simple { public:
Simple( int, float );
private:
int i ;
float f;
};

Simple::Simple( int ii, float ff ) : i(ii), f(ff)
// initialization {} // assignment

. , , . . , Simple :

Simple::Simple( int ii, float ff ) {
i = ii;
f = ff; // assignment phase }

. const , . , const . , , :

class ConstRef { public:
ConstRef( int ii );
private:
int i;
const int ci;
int &ri;
};

ConstRef::ConstRef( int ii )
{ // assignment
i = ii;// ok
ci = ii; // error: cannot assign to a const
ri = i; // error: ri is uninitialized }

. . ,

ConstRef::ConstRef( int ii ) : ci( ii ), ri( i )
// initialization
{ // assignment
i = ii; }

. . ,

class Random { public:
Random( int i ) : val( seed ( i ) ) {}
int seed( int );

private:
int val;
}

.

Word::Word( String &str, int cmt )
: name ( str ), occurs( cnt )
{} String msg( "hello" );
Word greetings( msg );

. . SynAntonym, , : wd, Word, synonym antonym, String. Word char* String&. wd.

class SynAntonym { public:
SynAntonym(char* s) : wd(s) {}
SynAntonym(char* s1, char* s2, char* s3) : wd(s1),
synonym(s2), antonym(s3) {}
~SynAntonym();

private:
String synonym;
Word wd;
String antonym;
};

SynAntonym sa1( "repine" );
SynAntonym sa2( "cause", "origin", "effect" );

sa1 sa2 :

1. :
String(); // synonym String member
String( "repine" ); // String member of wd
Word( "repine" ); // wd Word member
String(); // antonym String member

// sa1( "repine" );
String( "oridin" ); // synonym String member
String( "cause" ); // String member of wd
Word( "cause" ); // wd Word member
String( "effect" ); // antonym String member
// sa2( "cause", "oridin", "effect" );

2. .

. . .. . .

7-2. Buffer:
#inlcude "String.h"
class Buf
{ public: // ...
private: String buf; };

:

Stirng s1;
Buf();
Buf( 1024 );
Buf( s1 );

.

. - . .

class BinTree;
class INode
{ // private class
friend class BinTree;
int val;
BinTree *left;
BinTree *right;
};

class BinTree
{ public: // ... public intrface
private:
INode *node;
};

( 0) INode. INode : , . .

7-3. INode .
7-4. () INode.
7-5. () BinTree.
7-6. , 7-4 7-5.


: «1 2 3 4 5 6 7 »

,


© . 2006-2008. Created by: Site.bg
: IT | | . | Paparak.bg | | uchenik.com | TRAVEL | | AmAm.bg | . | | AnimeS-bg.com | | | | IT Light | Spodeli.net | - | IDG.BG | Teenproblem.net | - | Fresh-BG.com | Hanovete.com | Bulfleet.com | Mythlands.com | Ohoboho.com | .Com | News24 | Setcom.bg | Atol.bg | Elmaz.com | MobileBulgaria.com