Quote:Original post by Makaan
string q(); is a totally different story
Yes, because here you declare a function named q which takes no parameters and returns a string :)
I think you actually meant to write string q;
Quote:Original post by Makaan
string q(); is a totally different story
Quote:Original post by DevFred
I think you actually meant to write string q;
Quote:Original post by MakaanExcept I'm pretty sure string g(); declares a function named g that returns a string and takes 0 parameters.Quote:Original post by DevFred
I think you actually meant to write string q;
Yea , well, i usually write that way to make sure i see a constructor call there.
Quote:Original post by nobodynewsQuote:Original post by MakaanExcept I'm pretty sure string g(); declares a function named g that returns a string and takes 0 parameters.Quote:Original post by DevFred
I think you actually meant to write string q;
Yea , well, i usually write that way to make sure i see a constructor call there.
string s1; //default value: the empty string ""string s1("Ike"); //String initialized to Ikestring s1 = string(); //default value: the empty string ""string s2(); //function taking no argument returning a string
Quote:Original post by Vortez
Why the hell would you want to use a construtor/destructor for basic compiler type like int or BYTE when all you have to do is use the '=' like this -> int i = 0; ??? I think it would just overcomplicate things for nothing, + it's easier to read this way imo.
Quote:Original post by Vortez
Why the hell would you want to use a construtor/destructor for basic compiler type like int or BYTE when all you have to do is use the '=' like this -> int i = 0; ??? I think it would just overcomplicate things for nothing, + it's easier to read this way imo.
template<typename T>T default_construct(){ return T();}assert(default_construct<int>() == 0);assert(default_construct<std::string>() == "");