[Solved] index out of range C++/Qt

It means that i >= tanksLevel.size(). Check that. You may want to initialize your list with correct size first or use QList::append instead of operator[]. 2 solved index out of range C++/Qt

[Solved] How to fix ‘constructor is invalid use’ in C++?

Student is not a function that can be called on a Student* pointer. To construct an object call new Student. stu[i] = new Student(Name, id, age, cpp_score, cpp_count); Or even better: don’t use raw pointers, use a std::vector<Student>. Compare the CppCoreGuidelines for that. solved How to fix ‘constructor is invalid use’ in C++?

[Solved] How to Remove number from Extension with string?

You can use regex as shown or a simple LINQ query, i’d also recommend System.IO.Path: string originalPath = “Url1234.pdf”; string dir = Path.GetDirectoryName(originalPath); // in this case “” string extension = Path.GetExtension(originalPath); // .pdf string fn = Path.GetFileNameWithoutExtension(originalPath); // Url1234 string newFn = String.Concat(fn.Where(c => !Char.IsDigit(c))); // Url string newPath = Path.Combine(dir, newFn + extension); … Read more

[Solved] How does operator precedence affect order of evaluation?

Thus in a C++ program that is made up of value computations exclusively the evaluation order would entirely be dictated by operator precedence and associtivity. (2) No, the evaluation order of value computations is not entirely dictated by operator precedence and associativity. They impose only a partial ordering on evaluation. Consider a + b. In … Read more

[Solved] Printing pattern with only one inner loop [closed]

Inner loop ? Why would you need such a thing ? You can do it with a single for loop using std::string::string void print_stuff(unsigned width){ for(auto i = 0u ; i < width ; i+=1){ auto starAmount = width – i; auto spaceAmount = i; std::cout << std::string{spaceAmount, ‘ ‘} << std::string{starAmount, ‘*’} << ‘\n’; … Read more

[Solved] C++ Accessing Another Class Member [closed]

Simply add a getter method int get_x() to Class1 #include <iostream> #include <conio.h> using namespace std; class Class1{ private: int x; public: Class1(); void Display(); int get_x(); }; int Class1::get_x() { return x; } class Class2{ private: double z; public: Class2(); void Display(); Class2 Add(Class1); }; Class1::Class1(){ x = 1; } Class2::Class2(){ z = 5; … Read more

[Solved] Automatically check textbox length c# [closed]

You are looking for the TextChanged event. Write the method: protected void textBox1_TextChanged(object sender, EventArgs e) { if(textBox1.Text.Length >= 8) { // do things } } Then add it as a listener: textBox1.TextChanged += this.TextBox1_TextChanged; (If you’re using the Visual Studio designer you can select the TextBox, go to the Properties window, click the Events … Read more

[Solved] How to split a text file on c# [closed]

Dont make a habbit of asking ppl to write your code, but, in order to welcome you to the community: (you should make the code safer openning and closing the files.) public void Texts(FileInfo srcFile, DirectoryInfo outDir, string splitter = “dipendent”) { // open file reader using (StreamReader srcRdr = new StreamReader(srcFile.FullName)) { int outFileIdx … Read more

[Solved] Phone book project error.There are no errors found in compiler but it exits when it runs have been trying for very long [closed]

Your code does not make any sense. There are many problems with what you have written I’m not going to go through them all, but the most glaring is if (option == 1) { void addcontact(info contactlist[]); } This is not how a function is called. Instead, it should look like if (option == 1) … Read more

[Solved] How can I get the string between two tags [closed]

use this pattern: @”\[video.*?\](.*?)\[/video\]” and then get group 1. I won’t post the whole code because I dont want to do your work for you. Read about C# Regexes, Patterns and try to write your code with this pattern. 1 solved How can I get the string between two tags [closed]

[Solved] expected ‘)’ before object. class does not name a type [duplicate]

For starters, you should remove #include “Car.h” from Color.h. It creates an unnecessary circular include, and the compiler hits Car(Color a) before it knows that Color is a class. You also need to include the header <string> to output a string to cout. Next time, maybe don’t insult the people who are helping you. solved … Read more