Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / September 2007

Tip: Looking for answers? Try searching our database.

creating simple array... how to?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
buu - 23 Sep 2007 17:37 GMT
I'm trying to create a simple 2-dim array of integers, but don't know how to
do that...

in definition of class, I wrote:
int *results;

while in constructor:

results = new int[256][256];

but, I got an error: C2440: '=' cannot convert from int{*}[256] to 'int *'.

what is wrong?
PvdG42 - 23 Sep 2007 19:55 GMT
> I'm trying to create a simple 2-dim array of integers, but don't know how
> to do that...
[quoted text clipped - 10 lines]
>
> what is wrong?

Try this instead:

I'm assuming C++, as you don't specify.

int x[][] = new int[256][256];

The reason your attempt does not work is because a pointer to int is not the
same as an array name, although the array name (once the array is properly
declared) can be used as a pseudo-pointer to the array.
buu - 24 Sep 2007 06:24 GMT
>> I'm trying to create a simple 2-dim array of integers, but don't know how
>> to do that...
[quoted text clipped - 20 lines]
> the same as an array name, although the array name (once the array is
> properly declared) can be used as a pseudo-pointer to the array.

yes, it's c++

for the statement:
int x[][] = new int[256][256];

I got an error:
error C2440: '=' : cannot convert from 'int (*)[256] to 'int'
Peter Duniho - 24 Sep 2007 09:24 GMT
> yes, it's c++
>
[quoted text clipped - 3 lines]
> I got an error:
> error C2440: '=' : cannot convert from 'int (*)[256] to 'int'

Ah.  Well, the reason is the same as the person posted as "PvdG42" says,
but you want the managed C++ syntax instead.  Here's the doc page that
can help you with that:

http://msdn2.microsoft.com/en-us/library/fkzha470.aspx
PvdG42 - 24 Sep 2007 12:33 GMT
>>> I'm trying to create a simple 2-dim array of integers, but don't know
>>> how to do that...
[quoted text clipped - 28 lines]
> I got an error:
> error C2440: '=' : cannot convert from 'int (*)[256] to 'int'

As Peter says, I gave you standard C++, as you didn't indicate otherwise.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.