Board index » cppbuilder » Re: Using STL vector in a class? ( BCB2007 )

Re: Using STL vector in a class? ( BCB2007 )


2008-01-30 02:22:16 AM
cppbuilder7
Stephen R. Phillips wrote:
Quote
private: // User declarations
vector<log_error_ptr>my_errors; // <-- compiler reports //
type name expected It's complaining about the type "vector", not the
type "log_error_ptr"
Try..
#include <vector>
...
std::vector<log_error_ptr>my_errors;
...
- Roddy
 
 

Re:Re: Using STL vector in a class? ( BCB2007 )

Greetings people
I seem to be getting errors with the following code
----------------------8<----------------------
class TLog_Form : public TForm
{
__published: // IDE-managed Components
TMainMenu *Log_MainMenu;
TMenuItem *File1;
TMenuItem *Open1;
TMenuItem *N1;
TMenuItem *Exit1;
TPageControl *Log_PageControl;
TTabSheet *List_TabSheet;
TTabSheet *Data_TabSheet;
TTabSheet *Error_TabSheet;
TDrawGrid *Error_DrawGrid;
TDrawGrid *data_DrawGrid;
TRichEdit *Log_RichEdit;
TOpenTextFileDialog *Log_OpenTextFileDialog;
void __fastcall Open1Click(TObject *Sender);
void __fastcall data_DrawGridDrawCell(TObject *Sender, int ACol, int ARow,
TRect &Rect, TGridDrawState State);
private: // User declarations
vector<log_error_ptr>my_errors; // <-- compiler reports // type
name expected
vector<log_data_ptr>my_log; // <-- compiler reports // type
name expected
void ReadThisFile(AnsiString _file);
void do_error(AnsiString _error);
void do_data(AnsiString _data);
public: // User declarations
__fastcall TLog_Form(TComponent* Owner);
};
----------------------8<----------------------
I tried substituting double for the log_error_ptr and log_data_ptr to no
avail same error. I can assume this is "silly STL mistake 101" as I've
not used vector's before (seemed the thing to use at the time since I
don't know how much data or how many errors I will have). Hopefully
it's not "The STL is broken in BCB2007", is the answer (that would be my
good fortune of late).
Stephen
 

Re:Re: Using STL vector in a class? ( BCB2007 )

"Stephen R. Phillips" < XXXX@XXXXX.COM >wrote in message
Quote
I seem to be getting errors with the following code
Did you add #include <vector>to your code?
You are also not specifying any namespace when declaring your vector
instances. Do you have a 'using namespace' statement earlier in the code?
#include <vector>
using namespace std; // <-- here
class TLog_Form : public TForm
{
//...
private: // User declarations
std::vector<log_error_ptr>my_errors;
std::vector<log_data_ptr>my_log;
//...
};
If not, then have to explicitally specify the namespace when declaring the
instances:
#include <vector>
class TLog_Form : public TForm
{
//...
private: // User declarations
std::vector<log_error_ptr>my_errors;
std::vector<log_data_ptr>my_log;
//...
};
Gambit
 

{smallsort}