473,386 Members | 1,873 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,386 software developers and data experts.

Vectors within Structures

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 str{
vector< int >v1();
vector< int >v2();
} str;

However, I don't manage to use those vectors as usual, for example: str.v1[i]=n or str.v2.resize(j).

Is there any way to handle them throughout the program?

Any help would be wellcome. Thanks.
Sep 16 '07 #1
3 1452
ilikepython
844 Expert 512MB
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 str{
vector< int >v1();
vector< int >v2();
} str;

However, I don't manage to use those vectors as usual, for example: str.v1[i]=n or str.v2.resize(j).

Is there any way to handle them throughout the program?

Any help would be wellcome. Thanks.
Remove the parenthesis from the vector declarations and it should work. Whenever you want to declare an object with no arguments, leave off the parenthesis. Otherwise, the compiler thinks you are declaring a function.
Sep 16 '07 #2
Remove the parenthesis from the vector declarations and it should work. Whenever you want to declare an object with no arguments, leave off the parenthesis. Otherwise, the compiler thinks you are declaring a function.
Thanks ilikepython for your reply.
I've just done what you said and the compiler detedcs no error.
Now the problem is trying to build the .obj; it's showing 3 errors and I have no idea what they mean. Here is the message:

Linking...
Facturacion.obj : error LNK2001: unresolved external symbol "struct product * producto" (?producto@@3PAUproduct@@A)
Facturacion.obj : error LNK2001: unresolved external symbol "struct factur * factura" (?factura@@3PAUfactur@@A)
Debug/Facturacion.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

What should I review?
Thanks.
Sep 16 '07 #3
ilikepython
844 Expert 512MB
Thanks ilikepython for your reply.
I've just done what you said and the compiler detedcs no error.
Now the problem is trying to build the .obj; it's showing 3 errors and I have no idea what they mean. Here is the message:

Linking...
Facturacion.obj : error LNK2001: unresolved external symbol "struct product * producto" (?producto@@3PAUproduct@@A)
Facturacion.obj : error LNK2001: unresolved external symbol "struct factur * factura" (?factura@@3PAUfactur@@A)
Debug/Facturacion.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

What should I review?
Thanks.
That probably means the compiler can't find the definition of something. Can you post the Facturacion.cpp code?
Sep 16 '07 #4

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

Similar topics

9
by: Nancy Keuss | last post by:
Hi, I've created a vector of vectors of ints, and I want to pass it as a parameter to a function. Is this possible, and if so, then what is the syntax like for the function header and function...
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...
3
by: Obrecht | last post by:
Hi. I am new to VB .NET and am just starting to do some testing with it. I am trying to define a fixed length array of structures within a structure. I pass this structure to a Win32 Btrieve...
5
by: roberts.noah | last post by:
It is my understanding that if you contain vectors or maps you don't need to create copy constructors because the default calls that constructor. It is my understanding that if you use these types...
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...
2
by: joraara | last post by:
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...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.