468,467 Members | 2,634 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,467 developers. It's quick & easy.

heap and co.

Hi
i get error: 'record' was not declared in this scope
so i look in the header...nothing also nothing like DataRecord
but: unsigned long nRecords;
So what could that be?

record = new DataRecord[nRecords];

and how could i declare that? Propositions?
shouldn't record be like: record * ? but what type is record and DataRecord?
Thanks
Michael

Jul 7 '06 #1
8 1172
Hi
i get error: 'record' was not declared in this scope
so i look in the header...nothing also nothing like DataRecord
but: unsigned long nRecords;
So what could that be?

record = new DataRecord[nRecords];

and how could i declare that?
Thanks
Michael
One way would be...

DataRecord * record = new DataRecord[nRecords];

or...

std::auto_ptr<DataRecordrecord( new DataRecord[nRecords] );
but what type is record and DataRecord?
How are we supposed to know? Do a grep on your code and find out where
it's defined.
-Brian

Jul 7 '06 #2

"Michael Sgier" <sg***@nospam.chwrote in message
news:12***************************@news.hispeed.ch ...

"heap and co."? What's that subject supposed to mean? (Meaningful subjects
help people decide if they think they can help.)
Hi
i get error: 'record' was not declared in this scope
so i look in the header...nothing also nothing like DataRecord
but: unsigned long nRecords;
So what could that be?
That you haven't declared record anywhere, perhaps?
>
record = new DataRecord[nRecords];

and how could i declare that?
How can you declare record? From the line of code above, you probably want
a pointer to a DataRecord. That would be DataRecord*. (If you don't know
that, you _really_ need to open your books and read some more.)
Propositions?
What?
shouldn't record be like: record * ?
That would define record as a pointer to a type called record.
>but what type is record and DataRecord?
We have no way of knowing anything about the type DataRecord. You haven't
told us!

You probably just need "DataRecord* record;" somehwere. But since we can't
see your code, I have no idea where. Either as a member variable, a global
variable, or a local variable (somewhere in the function, before you use
it).

Howard
Jul 7 '06 #3
In article <11*********************@75g2000cwc.googlegroups.c om>,
wo**@brianmielke.com says...

[ ... ]
std::auto_ptr<DataRecordrecord( new DataRecord[nRecords] );
This gives undefined behavior (auto_ptr doesn't use the array form of
delete).

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 7 '06 #4
>
std::auto_ptr<DataRecordrecord( new DataRecord[nRecords] );

This gives undefined behavior (auto_ptr doesn't use the array form of
delete).
Right. Of course. I wasn't thinking.

-Brian

Jul 7 '06 #5
it get error: `DataRecord' is not a type

declared so in class CDatabase {
unsigned long nRecords;
int DataRecord[]; //i simply guessed this
CDatabaseRecord* record = new DataRecord[nRecords];
how should the line above look like?

actually i havent declred record anywhere. do i need in class
CDatabaseRecord to declare record? how?
what about DataRecord? thats an array? how do i declare it?`
Jul 8 '06 #6
originally only that code was in the project i try to compile:
record = new DataRecord[nRecords];

no declaration or record nor DatRecord...maybe explicitely to block out
stupid,lazy people like me ;-)
only this declaration:
unsigned long nRecords;
Thanks michael
Jul 8 '06 #7
Michael Sgier wrote:
it get error: `DataRecord' is not a type
Then that's probably true.
declared so in class CDatabase {
unsigned long nRecords;
int DataRecord[]; //i simply guessed this
Doesn't make sense. An array must have a size.
CDatabaseRecord* record = new DataRecord[nRecords];
This can't be written directly in a class definition.
how should the line above look like?
How would we know?
actually i havent declred record anywhere. do i need in class
CDatabaseRecord to declare record?
Depends. Is it supposed to be a member of that class?
how?
what about DataRecord? thats an array? how do i declare it?`
Again, how would we know? Declare it as whatever you need it to be.

Jul 8 '06 #8
"Michael Sgier" <sg***@nospam.chwrote in message
news:e7**************************@news.hispeed.ch. ..
it get error: `DataRecord' is not a type

declared so in class CDatabase {
unsigned long nRecords;
int DataRecord[]; //i simply guessed this
CDatabaseRecord* record = new DataRecord[nRecords];
how should the line above look like?

actually i havent declred record anywhere. do i need in class
CDatabaseRecord to declare record? how?
what about DataRecord? thats an array? how do i declare it?`
You have CDatabaseRecord, so it looks like your class for records is
CDatabaseRecord. So if you want an array of these, it would be:

CDatabaseRecord* records = new CDatabaseRecord[nRecords];
Jul 13 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Kevin Grigorenko | last post: by
17 posts views Thread by Jonas Rundberg | last post: by
2 posts views Thread by mordac | last post: by
9 posts views Thread by shine | last post: by
16 posts views Thread by sarathy | last post: by
reply views Thread by JosAH | last post: by
4 posts views Thread by ggoubb | last post: by
1 post views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.