, , .
, , . , , :
point<int> anyPoint(13, -5);
, new, :
point<double>* pOtherPoint = new point<double>(9.99. 3.33);
, .
.
//
template<class T> //
class Vector // Vector -
{T* data; //
int size; //
public:
Vector(int); //
~Vector () { delete [ ]data; } //
// [ ]
T& operator [ ] (int i) { return data[i];}
friend ostream & operator << (ostream&, Vector <T>);
};
template<class T> //
Vector <T>:: Vector(int n)
{data = new T[n];
size =n;}
// <<
ostream & operator << (ostream& out, Vector <T> X)
{ out<<endl;
for(int i=0;i<X.size; i++)
out<<X[i]<<" "; return out;}
, :
()
< >
( );
.. :
()
< >
Vector<char> A(5); //
//char, Vector <char> -
int main()
{clrscr();
// :
Vector<int> X(5);
Vector <char> C(5);
// :
Vector<int>*p= new Vector<int> (10);
// ,
// []
for(int j =0; j<10; j++)
{(*p)[j]= j; cout<< (*p)[j]<<" ";}
return;}
, , .
, , , , .
.
1. , , .
|
|
2. .
3. , .
:
1. . , , , .
2. . , , , .
3. . , , , , .
4. . , , , .
5. . , ( *), , ( ), - .
6. . , ( ), , ( ), - .
7. . , ( ), , ( ), - .
8. . , ( ), , ( ), - .
9. . , ( : ), ( ), , - .
10. . , , , .
4.
1. ,
2. , , .
3. .
|
|
1. ?
2. / ?
3. .
4. ? .
5. ?
6. , , ?
7. ?
8. ?
12
:
- , , -, ;
-
1. - .
2. - .