|
| HOMEPAGE | INDICE FORUM | REGOLAMENTO | ::. | NEI PREFERITI | .:: | RSS Forum | RSS News | NEWS web | NEWS software | |
| PUBBLICITA' | | | ARTICOLI | WIN XP | VISTA | WIN 7 | REGISTRI | SOFTWARE | MANUALI | RECENSIONI | LINUX | HUMOR | HARDWARE | DOWNLOAD | | | CERCA nel FORUM » | |
31-01-2004, 20.39.28 | #1 |
Member
Registrato: 12-06-2003
Messaggi: 65
|
Allocatori
#include <string> #include <iostream> #include <iterator> #include <algorithm> #include <fstream> #include <vector> #include <xmemory> using namespace std; class IntArray { public: //operazioni di uguaglianza e di disuguaglianza:#2b bool operator==(const IntArray&) const; bool operator!=(const IntArray&) const; //operatore di assegnamento?#2a IntArray& operator=( const IntArray& ); int size(); void sort(); int min() const; int max() const; int find (int value) const; private: }; void main() { string file_name; cout<<"Inserire nome file:"; cin>>file_name; ifstream infile(file_name.c_str(),ios::in); if (!infile) { cerr << "oops! unable to open file " << file_name << " -- bailing out!\n"; exit(-1); } else cout << '\n'; vector<string, allocator> *lines_of_text = new vector<string,allocator>; string textline; typedef pair<string::size_type, int> stats; stats maxline; int linenum=0; while (getline (infile,textline, '\n')) { cout<<"line read: "<<textline<<'/n'; if (maxline.first < textline.size()) { cout<< "line read:"<<textline<<'\n'; if (maxline.first< textline.size() ) { maxline.first=textline.size(); maxline.second=linenum; } lines_of_text->push_back( textline ); linenum++; } return lines_of_text; } Il programma non riesce a identificare gli allocatori; mi segnala: --------------------Configuration: Cpp1 - Win32 Debug-------------------- Compiling... Cpp1.cpp C:\Cpp1.cpp(50) : error C2955: 'allocator' : use of class template requires template argument list c:\programmi\microsoft visual studio\vc98\include\xmemory(72) : see declaration of 'allocator' C:\Cpp1.cpp(50) : error C2955: 'allocator' : use of class template requires template argument list c:\programmi\microsoft visual studio\vc98\include\xmemory(72) : see declaration of 'allocator' C:\Cpp1.cpp(50) : error C2512: 'vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator>' : no appropriate default constructor available C:\Cpp1.cpp(69) : error C2662: 'push_back' : cannot convert 'this' pointer from 'class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator>' to 'class std::vector<_Ty,_A> &' Reason: cannot convert from 'class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator>' to 'class std::vector<_Ty,_A>' Conversion requires a second user-defined-conversion operator or constructor C:\Cpp1.cpp(74) : error C2562: 'main' : 'void' function returning a value C:\Cpp1.cpp(34) : see declaration of 'main' C:\Cpp1.cpp(82) : fatal error C1004: unexpected end of file found Error executing cl.exe. Cpp1.exe - 6 error(s), 0 warning(s) Qalcuno sa come mai??
___________________________________
Portale Cattolico --- Per credenti e non... --- GoTo2001 (una volta conosciuto come X.Y.U. ...) |
Utenti attualmente attivi che stanno leggendo questa discussione: 1 (0 utenti e 1 ospiti) | |
Strumenti discussione | |
|
|