Questions tagged as 'c++'

1
answer

Kruskal Algorithm problem C ++

I'm implementing the Kruskal algorithm, but I'm having a problem because it's losing one of the links and its value, I already did an implementation in Dijkstra, but in the work I'm doing, Kruskal is the best one to be done, I'm not finding the...
asked by 27.06.2015 / 05:26
2
answers

Guess a number, and in the attempts, through the percentage show tips

I'm trying to create a game where the user must determine a range and guess a random number that is generated within this range. When the user enters a number to try to guess, the program must respond with one of the following messages: Theco...
asked by 30.11.2015 / 21:02
1
answer

Recursive functions in C ++: examples

I'm starting to learn in C ++ and, for the moment, I look at recursive functions. I have already seen some interesting examples, such as calculating the factorial of a number, but I would like to see other examples. I hope you do not consider th...
asked by 11.12.2015 / 02:07
1
answer

C ++ write to files

#include <fstream> #include <iostream> using namespace std; int main() { ofstream f_out; f_out.open("teste.txt"); if(! f_out.good()) return -1; else cout << "Arquivo criado!"; string str = "String...
asked by 12.05.2015 / 21:46
0
answers

Reference error in DLL

I am creating a DLL that needs to export 11 CEN / XFS functions, but there is a function that consumes a header file. I think the error is in consuming a method of a header that is not declared in my scope, anyone to help? This dll will commu...
asked by 20.01.2017 / 18:10
2
answers

Set values or not in c ++ variables

Good evening. Should I set values in variables when creating them in C ++? An example: int x = 0; int y; What's the difference in these two cases? And what happens in memory when I initialize it with 0 and without it.     
asked by 10.12.2015 / 23:48
2
answers

QMYSQL driver not loaded QtCreator

I'm trying to connect to the database with QtCreator as follows: this->db = QSqlDatabase::addDatabase("QMYSQL"); this->db.setHostName("localhost"); this->db.setDatabaseName("Pessoa"); this->db.setUserName("root"); this->db.setPa...
asked by 18.03.2014 / 23:30
2
answers

How to "clean" static variables?

In C ++ static variables are very important. Let's suppose I want to make a factorial that uses recursion. unsigned long long int RecursionFatorial(unsigned int fator) { static long long int FatReturn; if(fator == 0) { unsi...
asked by 05.02.2014 / 17:25
1
answer

Lexicon Analyzer using LEX

I'm using the LEX generator to do a lexical analysis of a simple code in C ++. The following code is from the generator: %{ #include<stdio.h> %} extern FILE *yyin; %% "<" {printf("(Identifier, %s)\n",&yytext[0]);} "&...
asked by 13.07.2016 / 16:56
4
answers

What are files with .cpp and .h extension?

What are these files with extensions .cpp and .h ? How do they interact?     
asked by 26.09.2017 / 14:47