"Protoman" <Pr**********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
| Why can't I write this?: int* array=new int[2]{1,010}; It keeps
saying:
|
| 8 C:\Dev-Cpp\test6.cpp expected `,' or `;' before '{' token
| 9 C:\Dev-Cpp\test6.cpp invalid type argument of `unary *'
|
| Any suggestions? Thanks!!!!
|
Ask yourself the following:
a) What does int* array do exactly?
answer: it *may* hold a pointer to a single integer.
So in the fragment:
int *p = new int(5);
delete p;
p is a pointer to a single integer. Not a container of integers.
b) What does
int array[2] = { 1, 10 };
do exactly?
answer: it creates a container of 2 integers initialized to 1 and 10
respectfully.
c) Since its now clear that a pointer to an integer can't do anything
else but potentially point to an integer, one can use the pointer to
"iterate" through a container of integer elements.
int array[2] = { 1, 10 };
int * p = array[0]; // p points to the first element
++p; // p now points to the second element: array[1]
So you can argue that setting the pointer to the container's first
element will naturally return the base address of the container. Except
that this is a rather dangerous statement since the grand majority of
containers are not organized in sequence in memory. In fact, the only
containers that are organized sequentially are:
primitive arrays
std::vector
a stack
(and thats a very short list of the available containers out there)
Hence, the C++ programmer makes a clear, unambiguous and critical
distinction between a pointer to a given element and a pointer (or
reference) to a given container.
Just cause you hold a pointer to a single car in a parking lot does not
give you the address of the parking lot.
Hey all,
Can someone help me figure out how to pass a dynamic array into a function?
Its been giving me some trouble, and my textbook of course doesnt cover the
issue. Its probably something...
Hi,
What can I use in C# for dynamic arrays ???? I have some records (struts in
..Net) and want to store them in a dynamic "arrays" or object list.
I noticed the in C# arrays' length can't be...
Here is a little code I wrote to add the numbers input by the
user.....I was wondering if its possible to have the same functionality
without using dynamic arrays.....just curious.....
...
Hi
Developemnt on win2003 server. Final server will be linux
Apache,Mysql and PHP is being used.
I use 2 scripts(form and process).
The form displays multiple dynamic rows with chechboxs,...
Howdy folks,
I've been working on a c project, compiling using gcc, and I've reached a problem. The assignment requires creation of a two-level directory file system. No files have to be added or...
Hello,
I am trying to find out how Dynamic Arrays are actually stored in memory. Really, I want to know how Vectors are stored in memory, but I deduce they are stored the same way.
If you...
Do dynamic arrays declared using ReDim have to be freed? I assume that
if it's an array of dynamically created objects (e.g.
Scripting.Dictionary), each one of those objects will have to be set
to...
Hi,
Is there a way in javascript to create Dynamic arrays or arrays on
fly.
Something Like:
var "ptsgN"+sd = new Array();
Here sd is incrementing by 1.
I have lots of data that I am...
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...