[Solved] error: ‘class std::vector’ has no member named ‘sort’

[ad_1] There is no std::vector<…>::sort. Instead, you will need to use std::sort: std::sort(orderedList.begin(), orderedList.end()); However, this will try to compare the pointers in your std::vector<Shape*> (hint: refactor this if at all possible). Instead, you will need to pass a custom comparator that dereferences the pointers: std::sort( orderedList.begin(), orderedList.end(), [](Shape *a, Shape *b) { return *a … Read more

[Solved] Reading TextBox List in C# [closed]

[ad_1] you can do this, on two way : First: string A = “Username:Password”; string Username = A.Substring(0, A.IndexOf(‘:’)); A = A.Substring(A.IndexOf(‘:’) + 1); string Password = A; Second: string A = “Username:Password”; string[] Items = A.Split(‘:’); string Username2 = Items[0]; string Password2 = Items[1]; 2 [ad_2] solved Reading TextBox List in C# [closed]

[Solved] What variations of vector-like containers already widely established? Do I have to write my own? [closed]

[ad_1] Here are the ones I know of: Traditional a.k.a. plain a.k.a. C array vector unique_ptr with an array-type template argument array valarray dynarray static_vector (see also here) small_vector stable_vector There are also “variable-length arrays” and “arrays with runtime bounds”, which do not exist in C++; the former exists in C. See also this question … Read more

[Solved] Why ArrayIndexOutOfBound Exception can be caught in Java, but C++ program crashes instead? [duplicate]

[ad_1] Since you were asked this question in an interview, the interviewer was probably trying to gain some knowledge about your understanding of principles behind C++ design. In this case, the principle the interviewer was looking to discuss is that in C++ you don’t pay for things that you do not explicitly request. Although bounds … Read more

[Solved] My basic cipher based encryption method in C++ is not working properly, how can I fix it? [closed]

[ad_1] I suggest placing all your valid characters into a string, then using the % operator. const std::string valid_characters = “abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*”; const unsigned int shift_offset = 13; std::string::size_type position = valid_characters.find(incoming_character); position = (position + shift_offset) % valid_characters.length(); char result = valid_characters[position]; You will have to check the position value because find will return std::string::npos … Read more

[Solved] CPP- I am getting Segmentation fault (core dumped)?

[ad_1] That’s why there are debug tools like gdb (just google for it 😉 ). This is the backtrace: #0 0x00000000004009ba in node::setnext (this=0x0, x=0x614cc0) at a.cpp:25 #1 0x0000000000400c18 in list::insertend (this=0x7fffffffdf10, x=45) at a.cpp:109 #2 0x00000000004008df in main () at a.cpp:137 that means in line 137 there is a function call (l.insertend(45)), then in … Read more

[Solved] How can I code a two-dimensional array of 50 rows and 50 columns into a function which randomly assigns an asterisk to an element?

[ad_1] How can I code a two-dimensional array of 50 rows and 50 columns into a function which randomly assigns an asterisk to an element? [ad_2] solved How can I code a two-dimensional array of 50 rows and 50 columns into a function which randomly assigns an asterisk to an element?

[Solved] Deserializing json C# [duplicate]

[ad_1] First your json is invalid. Here is the same one but with fixes. {“data”:[{“name”:”123″,”pwd”:123},{“name”:”456″,”pwd”:456},{“name”:”789″,”pwd”:789}],”duration”:5309,”query”:”myquery”,”timeout”:300} And with this json model should look like this: public class Rootobject { public Datum[] data { get; set; } public int duration { get; set; } public string query { get; set; } public int timeout { get; set; … Read more

[Solved] Problems with reversing line into file [closed]

[ad_1] A couple of comments/nitpicks, which may or may not solve your problem 🙂 if (!str || !(*str)) return NULL; Don’t do that. Don’t return NULL on empty strings, fputs() will barf. In my experience, it’s better to a) assert that the str pointer is non-null, b) return the empty string. begin=str+strlen(str)+1; *begin=’\0′; //?? There … Read more

[Solved] What does var[x] do?

[ad_1] This is a declaration of a Variable Length Array (VLA). The value of expression x (most likely, a variable) is treated as the number of array elements. It must have a positive value at the time the expression is evaluated, otherwise the declaration of the VLA produces undefined behavior. 8 [ad_2] solved What does … Read more