By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,908 Members | 1,147 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,908 IT Pros & Developers. It's quick & easy.

heap and co.

P: n/a
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
Share this Question
Share on Google+
8 Replies


P: n/a
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

P: n/a

"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

P: n/a
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

P: n/a
>
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
"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.