A
ArniLand
Написал программу которая представляет собой абстракцию текста с классом контейнером. Писал в VS 2008 professional, при компиляции выдает 4 ошибки, помогите пожалуйста разобраться что не правильно.
Список ошибок:
Список ошибок:
d:\мои документы\visual studio 2008\projects\laba3_class_conteiner _cpp\laba3_class_conteiner_cpp\laba 3_class_conteiner_cpp.cpp(32) : error C3646: 'string' : unknown override specifier
d:\мои документы\visual studio 2008\projects\laba3_class_conteiner _cpp\laba3_class_conteiner_cpp\laba 3_class_conteiner_cpp.cpp(32) : error C3646: 'max' : unknown override specifier
d:\мои документы\visual studio 2008\projects\laba3_class_conteiner _cpp\laba3_class_conteiner_cpp\laba 3_class_conteiner_cpp.cpp(32) : error C2761: 'std::string Texts::getMaxLenght(void)' : member function redeclaration not allowed
d:\мои документы\visual studio 2008\projects\laba3_class_conteiner _cpp\laba3_class_conteiner_cpp\laba 3_class_conteiner_cpp.cpp(32) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Код:
//[B]Row.h[/B]
#include <string>
#include <iostream>
using namespace std;
class Row
{
public:
string dataRow;
Row();
Row(string);
};
//[B]text.h[/B]
#include "Row.h"
const int countRows = 100;
class Texts
{
public:
Texts();
void addRows(string str);
void removeAll();
void removeRow(int numberRow);
string getMaxLenght();
string ToString();
Row texte[100];
int amountRows;
};
//Row.cpp
#include "stdafx.h"
#include "Row.h"
Row::Row()
{
}
Row::Row(string str)
{
dataRow = str;
}
//[B]text.cpp[/B]
#include "stdafx.h"
#include "text.h"
void Texts::addRows(string str)
{
texte[amountRows].dataRow = str;
amountRows++;
}
void Texts::removeRow(int numberRow)
{
for (int i = numberRow; i < (countRows - 1); i++)
{
texte[i] = texte[i+1];
}
texte[countRows - 1].dataRow = "";
amountRows--;
}
void Texts::removeAll()
{
for (int i = 0; i<countRows; i++)
{
texte[i].dataRow ="";
}
amountRows = 0;
}
string Texts::getMaxLenght()
string max = texte[0].dataRow;
for (int i = 1; i < amountRows; i++)
{
if (texte[i].dataRow.length() > max.length())
{
max = texte[i].dataRow;
}
}
return max;
}
string Texts::ToString()
{
string str = "";
for (int i = 0; i < amountRows; i++)
{
str = str + " " + texte[i].dataRow;
}
return str;
}
//main.cpp
#include "text.h"
#include "stdafx.h"
void main()
{
cout<<"Введите количество строчек: ";
int countRow;
cin>>countRow;
cout<<"Введите строчку: ";
Texts objText;
string temp;
for (int i=0; i < countRow; i++)
{
cin>>temp;
objText.addRows(temp);
}
cout<<"----\n\n"<<objText.ToString()<<"\n----\n";
cout<<"\nВведите номер строчки: ";
int numberOfRow;
cin>>numberOfRow;
if (numberOfRow < countRow)
{
objText.removeRow(numberOfRow - 1);
}
cout<<"----\n\n"<<objText.ToString()<<"\n----\n";
cout<<"\nСамая длинная строчка в тексте: "<<objText.getMaxLenght();
cout<<"\nОчистка текста.";
objText.removeAll();
cout<<"----\n\n"<<objText.ToString()<<"\n----\n";
}