[Solved] C++: What is best way to destruct this code? [closed]

C++: What is best way to destruct this code? You mean to free resources. In case of unordered_map The way to do it right is not to do it. A unordered_map will automatically release resources when it’s destroyed for anything allocated automatically. Unless you allocated the values with new, you don’t delete them. In case … Read more

[Solved] Using make_shared with char[] or int[] [closed]

Visual Studio 2015 doesn’t support the C++17 standard. Prior to C++17 standard you can’t have the std::shared_ptr<T[]> pointer. But even in C++17 the std::make_shared function doesn’t support array types so you would have to use the boost::make_shared instead. Another alternative is to use the unique pointer in combination with the std::make_unique which does support the … Read more

[Solved] why is this program taking integer and alpha numeric inputs and printing them? does std::string in c++ take integer values as well? [closed]

why is this program taking integer and alpha numeric inputs and printing them? does std::string in c++ take integer values as well? [closed] solved why is this program taking integer and alpha numeric inputs and printing them? does std::string in c++ take integer values as well? [closed]

[Solved] Extended for loop in C++

When for (int ai : a) std::cout << ai; is used for array – int a[20]; it can be substituted with for (int i = 0; i < sizeof(a) / sizeof(a[0]); i++) std::cout << a[i]; or with for (int *ai = a; ai < a + (sizeof(a)/sizeof(*a)); ai++) std::cout << *ai; But to work with … Read more

[Solved] In what circumstances does getcwd() return NULL?

Its documentation states: ERRORS The getcwd() function shall fail if: [EINVAL] The size argument is 0. [ERANGE] The size argument is greater than 0, but is smaller than the length of the pathname +1. The getcwd() function may fail if: [EACCES] Read or search permission was denied for a component of the pathname. [ENOMEM] Insufficient … Read more

[Solved] What happened to local pointer? [closed]

In foo() and foo2() you are returning pointers to local variables. These locals have automatic storage and it is undefined behavior to use a pointer to them once they go out of scope. Therefor p and p2 contain nothing useful. It might work, it might not. I can’t understand your question very well, so I … Read more

[Solved] Recommended unit testing tool to test web services, api calls and sql calls [closed]

You have mentioned Rhino Mocks, NUnit and TestDriven. I would not compare these against one another. However you can compare each of these with its counterparts. Here is a start! – I tried to include links for comparisons Unit testing Frameworks NUnit MsTest MBUnit xUnit NUnit vs. MbUnit vs. MSTest vs. xUnit.net I slightly prefer … Read more

[Solved] How to convert this code to LINQ [closed]

The other answers have shown how you can (and should, IMO) do this without LINQ – but they’ve both still got the same problem that your original code does: you’re only checking whether the data set has any tables – it could have fewer than tableNo tables. I would suggest: public bool IsNullOrEmptyDataTable(DataSet objDataset, int … Read more

[Solved] Combine elements of a list [closed]

Are you looking for this? var tupleList = new List<Tuple<string, string>>(); for (int i = 0; i < data.Count; i++) { for (int j = i + 1; j < data.Count; j++) { tupleList.Add(new Tuple<string, string>(data[i], data[j])); } } 1 solved Combine elements of a list [closed]

[Solved] C++ Classes/Confusion

And the program knows that you’re talking about the courseName variable. How is this possible since they are two different variables One was copied into the other, by virtue of passing it to a function. This is how functions work. Consult the first couple of chapters of your C++ book for more info. How does … Read more

[Solved] X, Y, XY why does this work in gcc? [closed]

It’s undefined behavior to use the value of an uninitialized (auto) variable that could have been declared with the register keyword (see 6.3.2.1p2 in the C standard). int XY; could have been declared with register (you’re not taking its address anywhere) and it’s still unitialized at the right hand side of int XY = XY;, … Read more