Category : assign

I have a function my_fun which returns random number. How can I do declaration and value check in one line? int x; if (x= my_fun()<0) if ((x= my_fun())<0) if ((x= my_fun()<0)) // this is what my IDE suggests but looks strange since those extra braces don’t help at all. Source: Windows Que..

Read more

I have a struct of Examinee like below (each has 1 id and their scores of different subjects): struct Examinee { string id; float math, literature, physic, chemistry, biology, history, geography, civic_education, natural_science, social_science, foreign_language; }; Now i want to write a function that reads from a string different values and assign them to an ..

Read more

I’ve one class named Message with constructors, copy constructor, redefined assign operator, a destructor and other functions for set and access to their attributes. In the assign operator function i call to the destructor for destroy old dynamic memory, for re-use and integrity in the code. But this it’s give me problems and i don’t ..

Read more