i went thro a few some days ago,
i got to nexe.gamedev.net
those are good tutorials for 3d,
but the i/o tutorials are a bit ehm well "undressed" they contain minimized information so you can do the most little..
you see?
so thats why i asked
sorry
tanks for the link!
i will get far with the vector + i/o info!!
till next time...
Jan
Arrays
heh. sorry.
these are also a good set of links:
click here
the first one is particularly good and contains a full example of reading a text file line by line. it''s what i used to get going on File I/O. the rest of the links on that goole page range from somewhat to not at all helpful. they contain some filler info that supports what the first link contains
-me
these are also a good set of links:
click here
the first one is particularly good and contains a full example of reading a text file line by line. it''s what i used to get going on File I/O. the rest of the links on that goole page range from somewhat to not at all helpful. they contain some filler info that supports what the first link contains
-me
ok so i tried the vector function
it works all fine,
accept for the resize function :/
i have been sitting on it the whole day but i can''t figure it out,
when i do this (i.e.):
struct Point
{
int x,y,z;
};
int i;
Point Points;
main()
for(i=0;i<5;i++){
Points.resize(i);
Points.x = i;
Points.y = i;<br>Points.z = i;<br>}<br><br>it produces an error(Tho winxp doesn''t show me which :/)<br><br>well thanks if you still wanna help,<br><br>Greetz<br><br>Fluid FX<br><br> </i>
it works all fine,
accept for the resize function :/
i have been sitting on it the whole day but i can''t figure it out,
when i do this (i.e.):
struct Point
{
int x,y,z;
};
int i;
Point Points;
main()
for(i=0;i<5;i++){
Points.resize(i);
Points.x = i;
Points.y = i;<br>Points.z = i;<br>}<br><br>it produces an error(Tho winxp doesn''t show me which :/)<br><br>well thanks if you still wanna help,<br><br>Greetz<br><br>Fluid FX<br><br> </i>
Ermm, that code is nonsense. You make one point and then try call resize() on it and index it as an array. And I see no declaration of a vector anywhere. I think you posted something wrong.
BTW, vector is not a function, it is a template.
[edited by - felonius on June 7, 2002 9:29:51 AM]
BTW, vector is not a function, it is a template.
[edited by - felonius on June 7, 2002 9:29:51 AM]
sorry
Point Points should be:
vector Points;
it was about the code i wrote but the real one is to big,
also it has the #include files and stuff...
only the resize doesn''t work :''(
Point Points should be:
vector Points;
it was about the code i wrote but the real one is to big,
also it has the #include files and stuff...
only the resize doesn''t work :''(
Simple Example
#include <iostream>
#include <vector>
.
.
.
typedef struct _POINT {
int x;
int y;
int z;
} POINT;
typedef std::vector POINTS;
.
.
.
POINTS vctPoints;
// Insert Example
for ( int i = 0; i < 5; i++ )
{
POINT Point;
Point.x = i;
Point.y = i;
Point.z = 1;
vctPoints.push_back(Point);
}
.
.
.
// Retrieving Elements from the Vector
POINTS::iterator it = vctPoints.begin();
while( it != vctPoints.end() )
{
std::cout
<< "X=" << (*it).x
<< ", Y=" << (*it).y
<< ", Z=" << (*it).z
<< std::endl;
it++;
}
If you know exactly how many items you will be storing you can
call vctPoints.reserve(SomeValue)
In your example, you do not need to resize the vector every time you insert a new item.
- Alek
#include <iostream>
#include <vector>
.
.
.
typedef struct _POINT {
int x;
int y;
int z;
} POINT;
typedef std::vector POINTS;
.
.
.
POINTS vctPoints;
// Insert Example
for ( int i = 0; i < 5; i++ )
{
POINT Point;
Point.x = i;
Point.y = i;
Point.z = 1;
vctPoints.push_back(Point);
}
.
.
.
// Retrieving Elements from the Vector
POINTS::iterator it = vctPoints.begin();
while( it != vctPoints.end() )
{
std::cout
<< "X=" << (*it).x
<< ", Y=" << (*it).y
<< ", Z=" << (*it).z
<< std::endl;
it++;
}
If you know exactly how many items you will be storing you can
call vctPoints.reserve(SomeValue)
In your example, you do not need to resize the vector every time you insert a new item.
- Alek
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement