,   CyberForum.ru

String - C++

C++ , http://www.cyberforum.ru/cpp-beginners/thread165449.html
. - , , . . #include "stdafx.h" #include <stdio.h> #include <windows.h> #include <wincon.h> #include <fstream> #include <iostream> #include <map> #include...
C++ clapack ! clapack. (http://www.netlib.org/clapack/readme.install) : Procedure for installing CLAPACK: ============================================================================== (1) 'tar xvf clapack.tar' to build the following directory structure: ? http://www.cyberforum.ru/cpp-beginners/thread165402.html
? C++
, ? . , . #include <iostream> #include <pthread.h> int S=0; int i; int j; int k; void * func_first(void * args) {
"-1.#IND" C++
, "-1.#IND". , . , , ? , dichotomy 0, .. "". , . #include "stdafx.h" #include <iostream> using namespace std; double func( double X ) {return X;}
C++ http://www.cyberforum.ru/cpp-beginners/thread165364.html
, ... : ( 5 6, ) , . , : #include <iostream.h> #include <stdlib.h> main() { int n; while ((n!=1) && (n!=2))
C++ , , -, -, - - . . . 2 2 4 4 ...

Alexey R
6 / 6 / 1
: 23.11.2009
: 608
13.09.2010, 14:37  []     String
easybudda
(unsigned short) ,
.
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
//Èñïîëüçîâ**èå êë*ññ* string.
#include <iostream>
#include <string.h>
 
using namespace std;
 
class String
{
      public:
            //Êî*ñòðóêòîðû
             String();
             String(const char *const);
             String(const String &);
             ~String();
             
             //Ïåðåãðóæå**ûå îïåð*òîðû
             char & operator[](unsigned short offset);
             char operator[](unsigned short offset) const;
             String operator+(const String&);
             void operator+=(const String&);
             String & operator= (const String&);
             
             //Îñ*îâ*ûå ìåòîäû äîñòóï*
             unsigned short GetLen()const { return itsLen; }
             const char * GetString()const { return itsString; }
      private:
              String (unsigned short);//ç*êðûòûé êî*ñòðóêòîï
              char * itsString;
              unsigned short itsLen;
}
 
//Êî*ñòðóêòîð. ç*ä***ûé ïî óìîë÷**èþ ñîçä*¸ò ñòðîêó *óëåâîé äëè*û.
String::String()
{
        itsString = new char[1];
        itsString[0] = '\0';
        itsLen=0;
}
 
//Ç*êðûòûé êî*ñòðóêòîð 
//èñïîëüçóåòñÿ òîëüêî ìåòîä*ìè êë*ññ* äëÿ ñîçä**èÿ ñòðîê òðåáóåìîé äëè*û
String::String(unsigned short len);
{
        itsString = new char[len+1];
        for (unsigned short i = 0);
        itsString[i] = '\0';
        itslen=len;
}
//ïðåîáð*çîâ**èå ì*ññèâ* ñèìâîëîâ â ñòðîêó.
String::String(const char * const cString)
{
       itsLen = strlen(cString);
       itsString = new char[itsLen+1];
       for (unsigned short i = 0; i<itsLen; i++)
       itsString[i] = cString[i];
       itsString[itsLen] ='\0';
}
//Êî*ñòðóêòîð-êîïèðîâùèê
String::String (const String & rhs)
{
               itsLen=rhs.GetLen();
               itsString = new char[itsLen+1]
               for (unsigned short i = 0; i<itsLen; i++)
               itsString[i] = rhs[i];
               itsString[itsLen] ='\0';
}
//Äåñòðóêòîð äëÿ îñâîáîæäå*èÿï*ìÿòè
String::~String()
{
                delete [] itsString;
                itsLen = 0;
}
//îïåð*òîð ïðèñâ*è**èÿ îñâîáîæä*åò ï*ìÿòü è êîïèðóåò òóä* string è size
String& String::operator=(const String & rhs)
{
        if(this == &rhs)
        return *this;
        delete [] itsString;
        itslen=rhs.Getlen();
        itsString = new char[itsLen+1];
        for (unsigned short i = 0; i<itsLen; i++)
        itsString[i] = rhs[i];
        itsString[itsLen] ='\0';
        return 8this;
}
//Íåêî*ñò**ò*ûé îïåð*òîð è*äåêñèðîâ**èÿ
//âîçâð*ù*åò ññûëêó ** ñèìâîë ò*ê. ÷òî åãî ìîæ*î èçìå*èòü!
char & String::operator[](unsigned short offset)
{
     if (offset > itsLen)
     return itsString[itsLen-1];
     else
     return itsString[offset];
}
 
//Êî*ñò**ò*ûé îïåð*òîð è*äåêñèðîâ**èÿ äëÿ ð*áîòû ñ êî*ñò**ò*ûìè îáüåêò*ìè
char String::operator[](unsigned short offset) ñùòûå
{
     if (offset > itsLen)
     return itsString[itsLen-1];
     else
     return itsString[offset];
}
 
//Ñîçä**èå *îâîé ñòðîêè ïóò¸ì äîá*âëå*èÿ òåêóùåé ñòðîêè ê  rhs
String& String::operator+(const String& rhs)
{
        unsigned short totalLen = itsLen +rhs.GetLen();
        String temp(totalLen);
        unsigned short  i;
        for (i = 0; i<itsLen; i++)
        temp[i] = itsString[i];
        for (unsigned short j = 0; j<rhs.GetLen(); j++, i++)
        temp[i] = rhs[j];
        temp[totallen]='\0';
        return temp;
}
 
//Èçìå*ÿåò åêóùóþ ñòðîêó è âîçâð*ù*åò void
void String::operator+=(const String&rhs)
{
     unsigned short rhsLen = rhsGetLen();
     unsigned short totalLen = itsGetLen + rhsGetLen;
     String temp(totalLen);
     unsigned short  i;
     for (i = 0; i<itsLen; i++)
     temp[i] = itsString[i];
     temp[totallen]='\0';
     *this = temp;
}
 
int main()
{
    String s1{"initial test"};
    cout << "S1\t" << s1.GetString() <<endl;
    
    char * temp = "Hello World";
    s1 = temp;
    cout << "S1\t" << s1.GetString() <<endl;
    
    chat tempTwo[20];
    strCpy(temptwo, "; nice to be here!");
    s1+= tempTwo
    cout << "TempTwo;\t" << tempTwo << endl;
    cout << "S1\t" << s1.GetString() <<endl;
    
    cout << "S1[4]\t" << s1[4] <<endl;
    s1[4]='0';
    cout << "S1\t" << s1.GetString() <<endl;
    
    cout << "S1[999]\t" << s1[999] <<endl;
    
    String s2(" Another string");
    String s3;
    s3 = s1 + s2;
    cout << "S3:\t" << s3.Getstring() << endl;
    
    String s4;
    s4 = "Why does this work&";
    cout << "S4:\t" << s4.Getstring() << endl;
    system("PAUSE");
    return 0;
}
:
28 C:\DC\Jess Liberty\12 12.cpp invalid use of non-static data member `String::itsString'
35 C:\DC\Jess Liberty\12 12.cpp from this location
35 C:\DC\Jess Liberty\12 12.cpp expected `]' before ';' token
36 C:\DC\Jess Liberty\12 12.cpp expected constructor, destructor, or type conversion before '=' token
36 C:\DC\Jess Liberty\12 12.cpp expected `,' or `;' before '=' token
37 C:\DC\Jess Liberty\12 12.cpp expected constructor, destructor, or type conversion before '=' token
37 C:\DC\Jess Liberty\12 12.cpp expected `,' or `;' before '=' token
38 C:\DC\Jess Liberty\12 12.cpp expected declaration before '}' token
 
: 11:57. GMT +3.
- , ,
-
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
@Mail.ru