Jump to content
  • Advertisement

Paulius Maruska

  • Content Count

  • Joined

  • Last visited

Community Reputation

566 Good

About Paulius Maruska

  • Rank
  1. Paulius Maruska

    std::vector and template problem...

    Quote:Original post by Rasmadrak In my code I do have a semicolon after the class declaration, and "using namespace std". That is a bad idea. Your ResourceManager class is a template class, so I'm safe to assume, that it is defined in a header file. Having "using namespace std" in a header file is a bad idea, because every source file that include the header, will also include the "using namespace std", which isn't always desired. So, just to be safe, I would suggest to explicitly add "std::" everywhere, instead of "using namespace std" in a header file. Just a tip. ;)
  2. Paulius Maruska

    Looking for source control software

    Quote:Original post by Reddox Hmm, thanks for the replies :) It's that TortiseSVN one that is extremely buggy. It keeps crashing explorer, not pretty at all :) I guess that turned my off of SYN. It's SVN not SYN. What version of Windows are we talking here? Maybe you're using something that isn't supported by TortoiseSVN? Either way, TortoiseSVN is very stable and not buggy. If you're experiencing problems, I'm pretty sure they're caused by some other shell extensions/software you have.
  3. Paulius Maruska

    C++ diamond inheritance problem

    Quote:Original post by jorgander I was hoping to achieve the functionality without adding any overhead, be it extra member variables or function parameters. Exactly like Base::Base() is called only once per DerivedBoth::DerivedBoth(), I'd like my own definable base function to be called once per derived function. Perhaps it is not possible though. Well, you can get away with not adding any new members. However, it would require RTTI. I'm not sure which one of those woould be better, but here's a proof of concept (it should compile & run without any changes - it worked for me): #include <iostream> #include <string> #include <typeinfo> using namespace std; class Base { public: virtual void Func() { cout << "Base::Func()" << endl; } }; class Derived1 : public virtual Base { public: virtual void Func() { cout << "Derived1::Func()" << endl; if(typeid(*this) == typeid(Derived1)) Base::Func(); } }; class Derived2 : public virtual Base { public: virtual void Func() { cout << "Derived2::Func()" << endl; if(typeid(*this) == typeid(Derived2)) Base::Func(); } }; class DerivedBoth : public Derived1, public Derived2 { public: virtual void Func() { cout << "DerivedBoth::Func()" << endl; Derived1::Func(); Derived2::Func(); if(typeid(*this) == typeid(DerivedBoth)) Base::Func(); } }; void run(Base & obj, string name) { cout << "======== " << name << endl; obj.Func(); cout << "========" << endl; } int main() { Derived1 d1; Derived2 d2; DerivedBoth db; run(d1, "Derived1 object"); run(d2, "Derived2 object"); run(db, "DerivedBoth object"); return 0; }
  4. Paulius Maruska

    C++ diamond inheritance problem

    Quote:Original post by jorgander Of course, as it stands now Base::Func will get called 3 times per call to DerivedBoth::Func, where I would like Base::Func to get called exacly once per call to Derived1::Func, Derived2::Func, or DerivedBoth::Func. you can check in Base::Func if it was already called. Something like this: class Base { public: Base * parent; bool funcCalled; virtual void Func() { if(!funcCalled) { // do some stuff parent->Func(); funcCalled = true; } } }; class Derived1 : public virtual Base { public: virtual void Func() { // do some stuff Base::Func(); } }; class Derived2 : public virtual Base { public: virtual void Func() { // do some stuff Base::Func(); } }; class DerivedBoth : public Derived1, public Derived2 { public: virtual void Func() { Base::funcCalled = false; // do some stuff Derived1::Func(); Derived2::Func(); Base::Func(); } };
  5. Paulius Maruska

    crash when i try to convert string to char*

    Font::Render() { RenderFont(WIDTH/2, 500, fontListBase, Fonts->question->Text.c_str()); } What is Fonts? Couldn't find it your code. Other than that, I would check if Fonts isn't NULL, then I would check if Fonts->question isn't NULL. Maybe try to step through this function in the debugger, and watch these values?
  6. Paulius Maruska

    How to lock a file in windows?

    Quote:Original post by spree Hey Guys, I"m developing using VS 2003 on c/c++ and I need to lock a file so I can use it as a mutex between threads and processes. I tried this code example from MSDN ( http://msdn2.microsoft.com/en-us/library/8w5bsb4f(VS.80).aspx ) You are using VS2003, but you are trying to compile an example written for VS2005 (I marked the parts of your post, that gives me this information). I'm not sure about the _lock_file and _unlock_file functions (I never used them), but I'm 100% sure that fopen_s and sprintf_s (and all other functions ending with _s) were added in VS2005. You can either try to install the latest version of Windows SDK (it comes with the latest version of the compiler and standard library), or you can get the newer version of VS (either 2005 or 2008 will do the trick).
  7. What about long long (__int64)?
  8. Paulius Maruska

    ostream and stuff

    It doesn't have to be derived from std::ostream. All you need is to write the operators.
  9. Paulius Maruska

    Objects design question

    Quote:Zao struct Foo { Foo(int x) : x(x) { } int x; }; This is completely unambiguous. The member variable x gets initialized with the parameter x. It may be unambiguous to the compiler, but what about the reader? I think it would, at least, confuse the reader... On the other hand, maybe the reader should get familiar with it so that it wouldn't confuse him... ;) Quote:Original post by ToohrVyk You can. struct Foo { Bar x, y; Foo(Bar x) : x(x), y(this -> x) {} }; Yes, but every time I'd do that - I'd get a warning about this pointer being used in the constructor initialization list. And considering the fact, that I always have "Treat warnings as Errors" enabled - this isn't going to work for me.
  10. Paulius Maruska

    Objects design question

    m_ is the only prefix I use in my code. I don't really like it, but I use it. Quote:Original post by ToohrVyk In those cases where you need disambiguating member variables from local variables, you can use this->bar. What about constructor initialization list? You can't use this->bar there... I saw some people are postfixing the constructor arguments with _, but I consider it even uglier than the m_ prefix...
  11. Paulius Maruska

    [C, C++] Is this function kosher?

    Quote:Original post by TheOddMan Quote:Original post by SiCrane Quote:Original post by TheOddMan Post increments are always carried out after a function call. No, they aren't. Function calls are sequence points; all function arguments must be fully evaluated before the function call. Yes it is, that's the whole point of postcrement / precrement operators. SiCrane is right - all arguments are evaluated before the function call. So, if you have foo(i++), the i++ part will be fully evaluated before execution enters the function foo. It's just that the value passed to the function will be a copy of value of i before it was incremented. Quote:Original post by TheOddMan Quote:Original post by SiCrane Quote:Original post by TheOddMan In the example you give, *tb++ = *ta++ is actually shorthand for: operator*( tb++ ) = operator*( ta++ ); No, it isn't. Prefix * is not, and can never be, a function call when applied to char * variables. You've obviously never heard of operator overloading then? You can not overload operators of built in types. You can only overload operators of in which at least one of the operands is your own class or structure. Pointer dereference operator is unary operation, so overloading it for char* is impossible.
  12. Paulius Maruska

    Templates and Typedefs

    You can always enclose the typedefs in a struct! template< Int32 N > struct FixedType { typdef Fixed< UInt64, N > U64; typdef Fixed< UInt32, N > U32; };
  13. Paulius Maruska

    New to this, a few questions.

    Quote:Original post by CodedFire Ive also noticed my rep has taken a hit because i voiced my opinion. How very democratic....... Dev-C++ is one of the worst choices today. Everyone on this forum knows that, so if you're recommending it to someone, then people are rating you as being unhelpful and/or unfriendly. No surprise there, really. As for your arguments. Visual C++ and auto-complete features won't actually auto-complete syntax things (like loops, or ifs) - it only does auto-complete on functions, classes and stuff like that. I really see no reason why one should choose Dev-C++ over any other C++ IDE. If you really don't like Microsoft, pick up CodeGear Turbo C++ or get Code::Blocks if you want... There is really no reason to get Dev-C++.
  14. Paulius Maruska

    No file output in ATL application

    I can't see anywhere in your given code, that you are flushing or closing the file (in which case it would be auto-flushed). You can also put std::endl into the stream - as far as I know, it flushes the stream too. On the other hand, the file should be auto-flushed and auto-closed when fout destructor is called, so I'm guessing that it's not called? And yeah, globals are bad. If that fout would be a local variable in the function - the destructor would take care of everything when you're returning from the function...
  15. Paulius Maruska

    Web game - Candy mountain massacre

    Yeah. The game is awesome! :)
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!