pekfos |
» 2014-08-18 17:55:54 Ta twoja funkcja jest bez sensu i ma niezdefiniowane zachowanie. |
|
NiceFox Temat założony przez niniejszego użytkownika |
» 2014-08-18 18:41:13 poprawiam się bool Greater( const Sygnal & a, const Sygnal & b ) { if( a.hi == b.hi ) return a.signal < b.signal; return a.signal > b.signal; } inline bool operator <( const Sygnal & a, const Sygnal & b ) { return a.hi < b.hi; }
sort( syg.begin(), syg.end(), Greater ); sort( syg.begin(), syg.end() ); obnie metody wywalają program z komunikatem jak w poprzednim poście , już nie wiem o co chodzi. syg.max_size() podaje że można zapisać 1,5mln rekordów, a wywala się przy sortowaniu. |
|
pekfos |
» 2014-08-18 22:06:59 Podaj cały kod. |
|
NiceFox Temat założony przez niniejszego użytkownika |
» 2014-08-19 11:08:50 baza.h #ifndef baza_h #define baza_h
#include "sqlite3.h" #include <string>
using namespace std;
class Baza { public: int rc; int rc2; sqlite3 * db_plik; };
class Sygnal
{ public: bool Greater( const Sygnal & a, const Sygnal & b ); Sygnal() : type( 0 ) { } Sygnal( string symbol, int brokersID, string signal, int type, string tf, string cdate, string ctime, double lo, float hi ); string symbol, signal, tf, ctime; int type, brokersID; float lo, hi; };
#endif
baza.cpp #include <ios> #include <iostream> #include "sqlite3.h" #include <process.h> #include <windows.h> #include "baza.h"
using namespace std;
Sygnal::Sygnal( string symbol, int brokersID, string signal, int type, string tf, string cdate, string ctime, double lo, float hi ) { this->symbol = symbol; this->brokersID = brokersID; this->signal = signal; this->type = type; this->tf = tf; this->cdate = cdate; this->ctime = ctime; this->lo = lo; this->hi = hi; } main.cpp #include "stdafx.h" #include <time.h> #include "baza.h" #include <iostream> #include <process.h> #include <time.h> #include <signal.h> #include <vector> #include <algorithm> #include <string> #include <sstream>
using namespace std;
void help();
vector < Sygnal > syg; vector < Sygnal > rest; vector < Sygnal > stat;
void __cdecl WatekStatystyka( void * Args );
template < typename T > std::string to_string( T const & value ) { stringstream sstr; sstr << value; return sstr.str(); }
bool Greater( const Sygnal & a, const Sygnal & b ) { if( a.hi == b.hi ) return a.signal < b.signal; return a.signal > b.signal; }
inline bool operator <( const Sygnal & a, const Sygnal & b ) { return a.hi < b.hi; }
int main() { Sygnal * sygnal = new Sygnal(); Baza * baza = new Baza(); HANDLE uchwytWatku3 =( HANDLE ) _beginthread( WatekStatystyka, NULL, baza ); char wybor = 'z'; for(;; ) { system( "cls" ); cout <<( "press key?? \n" ); fflush( stdin ); wybor = getchar(); switch( wybor ) { case 'h': help(); break; case 'q': return 0; } } }
void help() { system( "cls" ); cout <<( "q - wyjscie \n" ); }
void __cdecl WatekStatystyka( void * Args ) { Baza * baza =( Baza * ) Args; Sygnal * sygnal =( Sygnal * ) Args; for(;; ) { syg.push_back( Sygnal( "EU", 10000, "MA5", 0, "M15", "2014-08-18", "09:45", 1.3634, 1.3676 ) ); syg.push_back( Sygnal( "EU", 10000, "MA5", 0, "M15", "2014-08-18", "19:45", 1.3630, 1.3679 ) ); sort( syg.begin(), syg.end() ); for( size_t i = 0; i < syg.size(); ++i ) { std::cout << syg[ i ].symbol << " " << syg[ i ].signal << " " << syg[ i ].lo << ", " << syg[ i ].hi << std::endl; } } } kod skr óciłem , 1 rekord vectora to ok 100 zmiennych end Zacznij formatować swoje posty
~pekfos |
|
|
pekfos |
» 2014-08-19 12:49:27 kod skróciłem , 1 rekord vectora to ok 100 zmiennych
|
To jest kod wywołujący błąd..? vector napełniam w innym wątku
|
W innym niż teraz..? |
|
NiceFox Temat założony przez niniejszego użytkownika |
» 2014-08-19 13:13:45 aplikacja startuje, działa wywala się na sortowaniu:
Debug Assertion failed!
Program: C;/Users/Moje/sort.exe
File: C:\Program Files\Microsoft Visual Studio\10\VC\Include\vector Line 932 Expression: vector subscript out of range
(Press Retry to debug application)
Przepraszam za brak edycji kodu. Nie wiem jak to edytować, w FireFox nic nie wyświetla do edycji.
|
|
Monika90 |
» 2014-08-19 13:31:25 Dobrze, że wreszcie podałeś pełny komunikat błędu, ale zamieszczony wyżej kod się nie kompiluje, 'class Sygnal' has no member named 'cdate' . Podaj kod który faktycznie ma zachowanie które opisujesz. |
|
NiceFox Temat założony przez niniejszego użytkownika |
» 2014-08-19 16:41:46 stdafx.h #pragma once
//#include "targetver.h"
//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers // Windows Header Files: #include <windows.h>
// C RunTime Header Files #include <stdlib.h> #include <stdio.h> #include <strsafe.h> #include <string>
//#include <Winuser.h> #include <conio.h> //#include <fstream> #include <iostream> #include <cstring>
#include <memory.h> #include <ctime>
|
|
1 « 2 » 3 |