How do you define a default property for a c++ class? -


i want able able this:

mydatatype data1;  mydatatype data2;  data1 = "something"; data2 = data1; 

setting data1 easy because overload = operator. i'd able type line 2 is. without default property, have type as:

data2 = data1.thedesiredproperty; 

it seems me should possible this, because string class works in way. if replace "mydatatype" "string" (and inlcude string header file) don't have refer default property of string.

thanks.

i think useful thing here see example of how this:

class mydatatype {     public:         mydatatype(const char *message = ""): message_(message) {}          const char * message() const {             return message_;         }      private:         const char *message_; };   int main() {     mydatatype data1;     mydatatype data2;      data1 = "something";     data2 = data1;      mydatatype data3 = "something";     mydatatype data4 = data1; } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -