• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

354 Neutral

About daerid

  • Rank
  1. If you're using explicit template parameterization, what's wrong with something like this: class BaseResource { }; template< class T > class ResHandle : public BaseResource { /* etc, wraps a resource */ public: static ResHandle<T> LoadFromFile(const std::string& filename) { /* Load This type of resource from disk */ } private: T* mResource; }; class Resources { public: template< class T > ResHandle<T> Load(const std::string& filename) { std::map<std::string,BaseResource>::iterator found = mResCache.find(filename); if( found != mResCache.end() ) return found->second; else { ResHandle<T> res = ResHandle<T>::LoadFromFile( filename ); mResCache[ filename ] = res; return res; } } private: std::map<std::string,BaseResource> mResCache; }; Then you'd call it like this: class Obj { }; class Bmp { }; ResHandle<Obj> o = Resources::Load<Obj>("someobject.object"); ResHandle<Bmp> i = Resources::Load<Bmp>("somebmp.bmp");
  2. There is no way currently to turn that option off in VS.NET 2003. However, what I've found to be successful is that I code everything by hand in Source view, and then when I need to get the controls to show up in the code behind, I do this: 1. Switch To Design View - This will generate the proper designer generated code in the code-behind. 2. Switch Back to Source View 3. Hit Control+Z twice to undo formatting changes that Design View made. Since I can just hit Control+PageDown to toggle between design and source, it becomes a really quick 4-hit combo.
  3. Without reading the above link, I'm going to offer this little gem: Pluggable Abstract Object Factories. Great stuff!
  4. What is "The Stack"?

    Quote:Original post by Uphoreum Oh yea, I should've remembered that form my short assembly learning attempt, lol. So, dynamic memory (like "new"), isn't stored in the stack? Someone told me you can run out of stack space. Is this simply limited by the amount of memory the system has, or is it something else? While limited system memory can definitely be a factor, running out of stack space is usually caused by too much recursion (when a function ends up calling itself somewhere), or too many function calls being nested. Dyamic Memory (allocated with "new") is usually allocated from what's commonly known as "the heap" or "free store", which is usually by the operating system via API calls.
  5. You may have an unknown header #define somewhere that might rename GetCurrentTime in terms of some function GetTickCount
  6. Try this: template <typename T> Matrix<T>::Row operator*(typename const Matrix<T>::Row &, T); You may have to put the typename on the other side of the const, but I'm not sure.
  7. Sounds like you're talking about Concept Checks
  8. Quote:Original post by Ademan555 Well I can do that for everything but the map and vector classes, which will need to be templated, though, maybe i can totally avoid exposing them at all... thanks -Dan Unfortunately, you can't. If you're going to be distributing a library that exposes templated classes, then you'll have to include the source in the distribution. There's really no way around it.
  9. I actually don't understand how you can consider visual studio complex. I honestly feel it's the easiest IDE to use out there.
  10. Quote:Original post by guddi1 Is this the only way out? Of course it is. Think about it: "Interface" means the class is saying "I can do these things". If you declare that you can support an interface, must write the code that supports that interface.
  11. You need to fix the errors that the compiler reported. Specifically, since all those classes that start with I are interfaces, they provide no implementation. It is up to you to provide the implementation. Also, those are all COM interfaces, which is a pretty involved subject. What is it exactly that you are trying to accomplish?
  12. void foo(const int* ptr) { // do stuff with ptr } std::vector<int> vec; vec.push_back(1); vec.push_back(2); vec.push_back(3); foo(&vec[0]); // should work, maybe need to do &(vec[0])
  13. Blocks nested too deeply?!?

    4000 f'ing lines? Holy crap.
  14. ps: Why are you throwing strings?
  15. Zahlman, I believe you added an extra equals sign in 3)
  • Advertisement