A question about arrays.
Question posted by: Bilal Sallakh
(Guest)
on
July 22nd, 2005 04:48 AM
In this function:
int f() {
int A[];
// TODO...
}
What is the use of A? How to assign memory to A? and how to use it later?
4
Answers Posted
Bilal Sallakh wrote:
[color=blue]
> In this function:
>
> int f() {
> int A[];
> // TODO...
> }
>
> What is the use of A?[/color]
None.
[color=blue]
> How to assign memory to A?[/color]
Not.
[color=blue]
> and how to use it later?[/color]
You can't. The above should produce a compile error. You're trying to
create an array that has no size.
"Bilal Sallakh" <afkar@mail2world.com> wrote in message
news:d5fb3df3.0312010234.45aa1018@posting.google.c om...[color=blue]
> In this function:
>
> int f() {
> int A[];
> // TODO...
> }
>
> What is the use of A?[/color]
Invokes translator diagnostic.
[color=blue]
>How to assign memory to A?[/color]
int A[some_constant_expression];
or
int *A = new A[some_size];
[color=blue]
>and how to use it later?[/color]
Use it for what?
Which C++ book(s) are you reading?
-Mike
In turbo C++ from Borland Version 1 1990, a .c file raised a compile
time error while a .cpp file didn't. Is this up to the Compiler used?
If you have a question that is not related to a thread, please don't
post it as reply to it.
Bilal Sallakh wrote:
[color=blue]
> In turbo C++ from Borland Version 1 1990, a .c file raised a compile
> time error while a .cpp file didn't. Is this up to the Compiler used?[/color]
Yes.
|
|
|
What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 196,998 network members.
Top Community Contributors
|