473,396 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Vectors and Structures

Hi.

I hope someone would be able to help me with this:

I need to declare a structure composed by a couple of vectors. But I need those vectors to have an open dimension, I mean non-especific size (for example: short vector[]) so that the user doesn't have to be tied under a maximun limit.

I'm using Visual C++, but the compiler won't let me use such a way of declaring a vector inside the structure (although I can do it provided it's not inside a structure).

Any help would be useful. Thanks.
Sep 11 '07 #1
2 2353
gpraghuram
1,275 Expert 1GB
Hi.

I hope someone would be able to help me with this:

I need to declare a structure composed by a couple of vectors. But I need those vectors to have an open dimension, I mean non-especific size (for example: short vector[]) so that the user doesn't have to be tied under a maximun limit.

I'm using Visual C++, but the compiler won't let me use such a way of declaring a vector inside the structure (although I can do it provided it's not inside a structure).

Any help would be useful. Thanks.
Hi,
I cant understand why u want to specify the size of a vector using [].
Vector is dynamic and u can keep adding elements into it.
Better read the vector tutorial and you will get a clear idea.
Thanks
Raghuram
Sep 11 '07 #2
Banfa
9,065 Expert Mod 8TB
I cant understand why u want to specify the size of a vector using [].
I suspect the OP is using vector in it's mathematical sense rather than it's C++ type sense.


joraara, as gpraghuram says, in C++ there is a type vector. This type is a class that replaces the array, one of its main benifits being that you do not have to set it's size at compile time. The size can be set and changed at run time.
Sep 11 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Fred Ma | last post by:
Hello, I was looking at Meyers's "Effective STL", item 23 about choosing between vectors and maps (at least that the choice for me). In many cases, using sorted vectors is faster for lookups. ...
19
by: chris | last post by:
Hello, I've recently been trying to understand the various structures supplied by c++, and the one I find most confusing is deque. One quick question about this. It seems most implementations...
5
by: lugal | last post by:
This might be more appropriate here. I'm new to C++, coming from a background in another languages that allowed a similar solution to work (Python). I wrote the following code in C++ based on the...
2
by: Lee | last post by:
Hi, are there equivalents in c# as java vectors and hashmaps? thanks lee
2
by: code break | last post by:
Hi all. Please any one can tell me how we can use bit vectors to our project. Thanks for all..
13
by: JoeC | last post by:
I am completly lost. I would like to create a function that takes two vectors. These two vectors have objects with x and y coords, what I want to do find all the objects in the same x and y...
5
by: vasim98 | last post by:
I am surprised to see the output of the following C++ program using vectors. The program is so simple. An element is pushed in a vector "v" and the pointer to this element is obtained as "ptr_v"....
3
by: joraara | last post by:
Hi, I appreciate if someone is able to help me. I've declared a structure and two of it's members are vectors, let's say: #include <vector> using namespace std; struct...
1
by: Rob | last post by:
How would I do this? I want to be able to handle vectors of many different types of data and vectors that can contain any number of other vectors of data. Currently, I have a templated...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
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...
0
marktang
by: marktang | last post by:
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.