[Solved] Why does this program which finds the smallest triangle number with >500 factors crash? [closed]

TL;DR #include <vector> std::vector <unsigned long long int> triangleNumbers(0); int main() { triangleNumbers[0]=10000000000; } You have an empty vector, and the very first line in main leads to undefined behavior since you’re trying to access item 0 (there is no such item). Live Example using operator [ ] Live Example showing what vector::at() does Note … Read more

[Solved] Is it considered “correct” to use a template for a function/class that only accepts subclasses of a specific class?

It’s quite common, actually almost all templates have certain requirements towards their arguments. Those are usually implicitly clear from how the template parameter is used, but you can improve the error messages by using type traits. In C++11, they are available from the standard library via #include <type_traits>, otherwise look into Boost.TypeTraits. With C++11, the … Read more

[Solved] char () and int () are functions in c++? [duplicate]

Introduction Char () and int () are two functions in C++ that are used to convert data types. Char () is used to convert an integer value to its corresponding character value, while int () is used to convert a character value to its corresponding integer value. These functions are useful when dealing with data … Read more

[Solved] Making “Flappy Bird” Game In Unity3D (Flappy Plane), How To Destroy The Obstacles? [closed]

Is MonoBehaviour.Destroy(gameObject) what you’re after? I’m not really sure what part of the process you are struggling with? Edit: With the clarification, below is the revised answer: Track the position of the players co-ordinates, and when an object finds that its own co-ordinates are less that players co-ordinate minus the offset of where the player … Read more

[Solved] C program with pointer

In theory you can, by simulating individual data structures or even the entire memory (static data, heap and stack) with arrays. But the question is whether this is very practical; it may involve having to rewrite every pointer-based standard library function you need. Anyway, there’s a nice explanation on Wikipedia: It is possible to simulate … Read more

[Solved] Read and straighten multiple images from vector string, get error: “vector subscript out of range” [c++]

one of the problems in your code is, that you never check the results of your operations, there should be: M[i] = imread(“Klasa_pierwsza\\” + lista[i]); if ( M[i].empty() ) { cerr << “Klasa_pierwsza\\” + lista[i] << ” could not be loaded !” << endl; continue; } // … std::vector<cv::Vec4i> lines; cv::HoughLinesP(bw, lines, 1, CV_PI / … Read more

[Solved] WebRequest not returning HTML

You need CookieCollection to get cookies and set UseCookie to true in HtmlWeb. CookieCollection cookieCollection = null; var web = new HtmlWeb { //AutoDetectEncoding = true, UseCookies = true, CacheOnly = false, PreRequest = request => { if (cookieCollection != null && cookieCollection.Count > 0) request.CookieContainer.Add(cookieCollection); return true; }, PostResponse = (request, response) => { … Read more

[Solved] C++ functions, pass by reference

I’m not going to answer with a complete solution (and you are free to improve your question so you get better answers later), but regarding the question title, here are some hints. Your declaration char displaymenu(int num1, int num2); and your definition char displaymenu(int &num1 = num1, int &num2 = num2) should have the same … Read more