std::vector of Pointers (Client*) vs Objects?<aside> ⚠️
Memory Management Reality Check Understanding pointer semantics is critical for IRC server stability.
</aside>
Client*, you maintain a reference to an object that exists elsewhere (likely in a Server's master client list). Multiple channels can point to the same client without copying.Client objects directly in a vector, copying them would slice off derived class information (if you ever extend Client).Client objects every time you add/remove from a channel would be expensive. Pointers are 4-8 bytes; objects could be hundreds.The Trade-off:
std::map Iterators in C++98 Loop Syntax<aside> 📚
C++98 Iterator Constraints
No range-based for loops. No auto. Manual iterator management only.
</aside>
std::map<std::string, Channel*>::iterator it;std::map<std::string, Channel*>::const_iterator it;it = myMap.begin()it != myMap.end()++it (prefer pre-increment for iterators)it->first gives you the key (e.g., channel name)it->second gives you the value (e.g., Channel* pointer)map.erase(it) invalidates the iterator!next_it = current_it; advance next_it; erase current_it; current_it = next_it;map.find(key) which returns an iteratorif (it != map.end()) before dereferencingCommon Pitfalls: