Questions tagged as 'c++'

2
answers

How to check if a type is numeric in C ++?

Let's suppose I have a function: template<class T> T soma(const T& x, const T& y) { static_assert(/*O tipo é for numérico?*/, "Tipo de argumento inválido, O argumento precisa ser numérico"); return x + y; } Can you tel...
asked by 09.08.2018 / 23:27
2
answers

Removing repeated values

I have two vectors , each with (x, y) coordinates. I need to invert the second vector , getting with (y, x) and merge with the first, but I can not get repetition in the first field, so I thought I'd use a set . However, I need the second...
asked by 15.03.2014 / 15:43
1
answer

When the destructor of an object is called in C ++?

Let's suppose I have a function: std::string empty_string() { std::string x{ "" }; return x; } As much as it seems normal, it gets kind of confusing when we think: When the destructor of object x is called? Please no...
asked by 11.08.2018 / 04:15
3
answers

C ++ Challenge, help with logic

I received a list of exercises from the programming teacher, this is a challenge.    write a function with either return the value of the expression y = i - i^2 + i^3 -i^4 +i^5 - ... +- i^n I thought about doing recursion , but I...
asked by 20.09.2015 / 20:53
3
answers

What is the problem of allocating memory with new and then not deleting?

What can happen if I use new to allocate memory and then not release it? And when it is in the situation below, that I can not erase the allocated memory, since I need to return, what do I do? const char* enc(const char* Str) { auto len...
asked by 07.03.2018 / 01:35
2
answers

Should I avoid repeated access to the same method within a loop?

I worry about the final performance of an executable at the same time, I do not want to penalize the programmer with excessive or unnecessary care in the code. In the code below, for example, it will return the same value as the getPositio...
asked by 21.05.2018 / 03:06
3
answers

Why is a named vector inside?

I would like to know the function of using a name within a vector? char chave[NUM_LETRAS + 1]; int frequencias[NUM_LETRAS]; int frequencias2[NUM_LETRAS]; char codificado[MAX_STR]; char descrip[MAX_STR];     
asked by 24.04.2018 / 21:55
1
answer

How to make an interface in C ++?

Java, C #, and other languages have the interface concept, which is very useful in some circumstances. How to make an interface or the closest to it in C ++?     
asked by 07.05.2016 / 01:15
1
answer

When to use cin.ignore () in C ++?

What is the exact time to use cin.ignore() in software written in C ++? Why a lot of the time, when I'm doing a big software, the readings are bugging, sometimes if I put cin.ignore() debugging, sometimes it buga more. So, what'...
asked by 02.08.2018 / 20:17
2
answers

Convert natural number to binary recursively

How can I make this function into a recursive function? I was able to do it iteratively this way: #include <iostream> using namespace std; int main (){ int n,pot,bin; cout << endl << " Digite o Numero: "; cin &...
asked by 10.02.2015 / 16:20