•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 402,053 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,448 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 276 | Replies: 9
![]() |
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,694
Reputation:
Rep Power: 36
Solved Threads: 878
you can do this:
The above will let you add as many Character class objects as you want to the vector.
vector<Character> characters;
The above will let you add as many Character class objects as you want to the vector.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
•
•
Join Date: Jun 2008
Posts: 74
Reputation:
Rep Power: 1
Solved Threads: 0
ok but when creating objects I do not no how to append something to the name of the object to differentiate it from the others because at one point 3 people could be logged into my game and at another 7 people could be so I have to be ready to know how to create objects dynamically if you no what I mean
>if you no what I mean
No, I don't. It seems like you don't feel your question has been answered adequately. If that's the case, post your code so we can see what you're doing now and can get a better idea of what you might be asking for.
No, I don't. It seems like you don't feel your question has been answered adequately. If that's the case, post your code so we can see what you're doing now and can get a better idea of what you might be asking for.
I'm a programmer. My attitude starts with arrogance, holds steady at condescension, and ends with hostility. Get used to it.
•
•
Join Date: Jun 2008
Posts: 74
Reputation:
Rep Power: 1
Solved Threads: 0
I have no idea where to start with this concept, I will explain it deeper so maybe you can get a feel for what I am trying to ask.
Ok so I have a class called OtherCharacter and its filled with all the attributes that have to be loaded by the client when there is other characters in the game. But sometimes it is five people and sometimes its 20, so I need a way even if It is not vectors to create an object of the othercharacter class for every person on the server. I don't need the networking part of it just how to create an object dynamically almost.
Ok so I have a class called OtherCharacter and its filled with all the attributes that have to be loaded by the client when there is other characters in the game. But sometimes it is five people and sometimes its 20, so I need a way even if It is not vectors to create an object of the othercharacter class for every person on the server. I don't need the networking part of it just how to create an object dynamically almost.
I think you're confused. Just use vectors where you need more than one instance of any kind of data. When you create a character, also add that character to the list of "other characters". It doesn't seem like a terribly difficult thing to me, but then again, you're still not being very clear.
I'm a programmer. My attitude starts with arrogance, holds steady at condescension, and ends with hostility. Get used to it.
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,694
Reputation:
Rep Power: 36
Solved Threads: 878
as previously mentioned, vector class doesn't care how many items you put into it, nor does it care when you do it. You can put an item into the vector at any random times. So when someone logs onto your game, fills out all the information needed for that character class, just add an instance of that class into the vector. The vector class will grow by itself as you add more objects to it.
Mabe what you want is a quick tutorial (click here)
Mabe what you want is a quick tutorial (click here)
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- How to overload + operator for STL Vectors (C)
- C++ question on alternating sums (C++)
- minor problem with vectors and OOP (C++)
- vectors (C++)
- Help with vectors and structs (C++)
- help with vectors (C)
- Vectors, Functions, and Sorting... oh my! (C++)
Other Threads in the C++ Forum
- Previous Thread: 4 functions
- Next Thread: Program Direction Advice Please



Linear Mode