well for the mystring function i will say:
i wanted to be able to pass a string obj to the function and made the *this default so it would work both ways. eg:
but i have changed my functions, they don't take any arguments now and modify *this and return it as well.
sting std_str = "ABC";
//and on its own like this
Bad. If you want a lower_case that can take another string object (which you really shouldn't need), make it static. This gives the effect that it's available in a namespace like mystring::lower_case and not part of the object itself.
To be better, you could create a namespace named String and put that function there instead.
Oh My GOD ! ! !
I Love You Elysia! Thanks a lot :)
The MSVC is doing all the completions etc. stuff with Qt API now :)
And for building I can still use the same old command line method (until I find a way with MSVC).
I seriously recommend against it.
Originally Posted by manav
You are breaking lots of stuff in the code. If your code throws, it won't work as it should, for example (since you have disabled C++ exception handling!!). And who knows what else you've broken by compiling manually?
At least set up your project as it should compile and copy the command line from the GUI. At least do that. Microsoft's compiler is a complex beast that wasn't really meant to be used in CLI I bet, since they did it overly complex.
me too don't have any idea about good/bad command line options for cl but these are the options that i am using:
i hope somebody who understands cl can tell how good/bad these options are!
DEFINES = -DUNICODE -DQT_LARGEFILE_SUPPORT -DWIN32 -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT
CFLAGS = -nologo -Zm200 -GS -Od -ZI -Gm -MDd -W3 $(DEFINES)
CXXFLAGS = -nologo -Zm200 -GS -Od -ZI -Gm -MDd -GR -EHsc -W3 $(DEFINES)
EDIT: the above are for DEBUG mode.
here are RELEASE mode options:
DEFINES = -DUNICODE -DQT_LARGEFILE_SUPPORT -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT
CFLAGS = -nologo -Zm200 -GS -O1 -MD -DNDEBUG -W3 $(DEFINES)
CXXFLAGS = -nologo -Zm200 -GS -O1 -MD -DNDEBUG -GR -EHsc -W3 $(DEFINES)
Huh? None of those are cl commands.
They all begin with "/" contrary to the linux standard of "-" which is really annoying rather than the "/" in my opinion.
And you aren't even using highest warning level, which is another reason you should avoid your manual compile alternative.
no tested it. cl understands options starting with the hyphen.
Sneaky Microsoft :p
Doesn't mention such a thing in the docs.
But do say, when it's multi-platform, they always introduce this unneccesary and stupid stuff. Using a makefile for compiling the project is stupid as you lose every functionality in the project settings.
Try this guide as well:
But ignore the advice about disabling precompiled headers.
Don't make the function static. Make it a free function as anon mentioned and don't derive from std::string at all. There's no reason to, it just creates unnecessary complexity. lower_case(my_str) is just as easy to call as my_str.lower_case().
Not to mention that it's actually more flexible: You can do my_str3 = lower_case(my_str1 + my_str2);
Originally Posted by Daved
Well, I think you could do my_str3 = (my_str1 + my_str2).lower_case() too, but I don't really want to argue for that syntax.
Ok, it's not something I would write, but I give you that it would be valid thing to do - but most people wouldn't even understand what it does...
Originally Posted by Daved
Edit: It's when I see things like that, that I remember that I don't know C++ well enough - although I don't want to write code like that, I would at least want to know that it can be done... ;-)
Obviously it might have its uses, but I don't recommend placing such a function inside the mystr class. It's not part of the class because it only modifies and returns the data from the argument, so it may well be placed outside the class and using public methods in the class for better encapsulation.
Originally Posted by matsp
And what better place to put than inside a namespace such as String, where all your string functions are gathered?