vector<Sprite*> box;
+++++++++++++++ +++++++++++++++ ++++
tank = new Bitmap(hdc, IDB_IMAGE2, g_hin);
Sprite * ms = new Sprite(tank, rcBounds, BA_BOUNCE);
break;
box.push_back(m s);
+++++++++++++++ +++++++++++++++ +++++++++
for(vector<Spri te*>::iterator itr = box.begin();
itr != box.end(); itr++){
itr->Update();
}
This isn't working how can I do it better? 14 1416
"JoeC" <en*****@yahoo. com> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com...
vector<Sprite*> box; +++++++++++++++ +++++++++++++++ ++++ tank = new Bitmap(hdc, IDB_IMAGE2, g_hin); Sprite * ms = new Sprite(tank, rcBounds, BA_BOUNCE); break;
box.push_back(m s);
+++++++++++++++ +++++++++++++++ +++++++++
for(vector<Spri te*>::iterator itr = box.begin(); itr != box.end(); itr++){ itr->Update();
- }
This isn't working how can I do it better?
(*itr)->Update();
-Mike
On 6 Dec 2005 11:40:39 -0800, "JoeC" <en*****@yahoo. com> wrote:
vector<Sprite* >box; ++++++++++++++ +++++++++++++++ +++++ tank = new Bitmap(hdc, IDB_IMAGE2, g_hin); Sprite * ms = new Sprite(tank, rcBounds, BA_BOUNCE); break;
box.push_back(m s);
++++++++++++++ +++++++++++++++ ++++++++++
for(vector<Spri te*>::iterator itr = box.begin(); itr != box.end(); itr++){ itr->Update(); }
This isn't working how can I do it better?
WHAT isn't working?? No way to tell from this snippet of incomplete
code.
--
Bob Hairgrove No**********@Ho me.com
JoeC wrote: vector<Sprite*> box; +++++++++++++++ +++++++++++++++ ++++ tank = new Bitmap(hdc, IDB_IMAGE2, g_hin); Sprite * ms = new Sprite(tank, rcBounds, BA_BOUNCE); break;
box.push_back(m s);
+++++++++++++++ +++++++++++++++ +++++++++
for(vector<Spri te*>::iterator itr = box.begin(); itr != box.end(); itr++){ itr->Update(); }
This isn't working how can I do it better?
FAQ 5.8, I believe, should help to get closer to the solution.
V
I got help with now problem. It was pretty basic.
But box.push_back(m s); Is still viving me an error. It says that
ms is not declared.
I have still to look up they syntax of the switch/case part
42 C:\Documents and Settings\Owner. ROOT\My
Documents\C++\E ngineII\action. cpp `ms' undeclared (first use this
function)
"JoeC" <en*****@yahoo. com> wrote in news:1133898039 .843277.38830
@o13g2000cwo.go oglegroups.com:
vector<Sprite*> box; +++++++++++++++ +++++++++++++++ ++++ tank = new Bitmap(hdc, IDB_IMAGE2, g_hin); Sprite * ms = new Sprite(tank, rcBounds, BA_BOUNCE); break;
box.push_back(m s);
+++++++++++++++ +++++++++++++++ +++++++++
for(vector<Spri te*>::iterator itr = box.begin(); itr != box.end(); itr++){ itr->Update(); }
This isn't working how can I do it better?
1st... handy to post what you mean by "This isn't working".
2nd... the type of *itr is Sprite*
So.... (*itr)->Update();
Thanks, I got that but still the push back part is not working it is
saying that ms is not declared.
"JoeC" <en*****@yahoo. com> wrote in message
news:11******** ************@g4 7g2000cwa.googl egroups.com... I got help with now problem. It was pretty basic.
But box.push_back(m s); Is still viving me an error. It says that ms is not declared. I have still to look up they syntax of the switch/case part
42 C:\Documents and Settings\Owner. ROOT\My Documents\C++\E ngineII\action. cpp `ms' undeclared (first use this function)
Judging from the indentation in the incomplete code you posted, I suspect
you're inside some kind of loop or switch statement when ms is declared.
Instead of declaring it inside that block, you could declare it before the
block. Or perhaps, instead, you need to move the push_back to immediately
after the line where you declare the ms variable (and create its instance)?
But we can't tell from your sparse example which approach is appropriate.
-Howard
JoeC wrote: vector<Sprite*> box; +++++++++++++++ +++++++++++++++ ++++ tank = new Bitmap(hdc, IDB_IMAGE2, g_hin); Sprite * ms = new Sprite(tank, rcBounds, BA_BOUNCE); break;
box.push_back(m s);
+++++++++++++++ +++++++++++++++ +++++++++
for(vector<Spri te*>::iterator itr = box.begin(); itr != box.end(); itr++){ itr->Update(); }
This isn't working how can I do it better?
What's Sprite?
Looks like sprite is a pointer, and your iterator is a "pointer" so
you'll need to dereference twice.
Ben Pope
--
I'm not just a number. To many, I'm known as a string... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: BCC |
last post by:
If I create a vector of vectors of double:
std::vector< std::vector<double> > table1;
Are my vectors of doubles uninitialized? Do I have to loop through table1
and initialize each vector of doubles using new?
And in cleaning up, manually delete each of these vectors of doubles?
Thanks,
|
by: mosfets |
last post by:
Hi,
I'm having a little trouble figuring out the difference in terms of
memory allocation between:
class person_info;
class A {
private:
|
by: Dr. J.K. Becker |
last post by:
Hi all,
I have vectors that holds pointers to other vectors, like so:
vector<whatever> x;
vector<whatever*> z;
z=&x;
Now I add something to x
|
by: Matthias Kaeppler |
last post by:
Hi,
in my program, I have to sort containers of objects which can be 2000
items big in some cases. Since STL containers are based around copying
and since I need to sort these containers quite frequently, I thought
it'd be a better idea to manage additional containers which are
initialized with pointers to the objects in the primary containers and
sort those (only pointers have to be copied around then).
However, that also means if I...
|
by: kathy |
last post by:
I am using std::vector in my program:
func()
{
std::vector <CMyClass *> vpMyClass;
vpMyClass.push_back(new CMyClass());
vpMyClass.push_back(new CMyClass());
vpMyClass.push_back(new CMyClass());
//???? Required ??????????????//
| |
by: jagguy |
last post by:
I am a little confused with the basic concept of vector of pointers.
The vector is easy enough.
Say you want a vector of pointers to int. The integers are not created
outside the vector so all we get is this and it doesn't work
vector<int*> ones;
ones->push_back(7);
//this failed to *ones.push_back(7)
ones->push_back(8);
|
by: JoeC |
last post by:
I am writing a game and I am having a challenge with my combat
function. All I want to do is find out how to group pieces that are in
the same space. There are two sides and all the units that are in the
same space fight. I want to add up the attack factors and defending
factors in the same space then figure out the odds so I can roll
against an odds table. Basically each piece holds its own x and y loc.
Here is what I have right...
|
by: JoeC |
last post by:
I am writing a program and I would like to pass an array of objects to
a function and from that object I want to return a valuse to that
function how do I do it?
Here is what I have:
terrain * t; <- an array of different kinds of terrain.
This is the line of code:
int mod = t->getDef();
|
by: nabh4u |
last post by:
Hi,
I have a problem referencing to Vectors using pointers i.e. I am not able to use "call by reference" on vector variables.
I have a "read()" function in "x.cpp" and "main()" in "y.cpp". I have 3 vector variables in Main(). I want the read function to read the values into the vector using the address I send of the vectors..
Sample code:
//x.cpp
void read(vector <int> a,vector <int> b,vector < vector <int> > c)
|
by: raphfrk |
last post by:
Is this valid?
int a;
void *b;
b = (void *)a; // b points to a
b += 5*sizeof(*a); // b points to a
a = 100;
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |