Questions tagged as 'c++'

2
answers

Reading files in c ++

I have a Store class with a method to read users of a file: void Store::leerUsuarios(const string &nombreFichero){ ifstream fichero; fichero.open(nombreFichero); if (fichero.is_open()) { string nom, mail, contrasenya; while (!...
asked by 26.05.2018 / 02:17
1
answer

Constant expressions to detect the presence and value of macros

I am making great efforts to translate the macros of my projects to constant expressions that can be used with if constexpr . At the moment I have achieved almost satisfactory results doing some tricks with macros, I start defining macros...
asked by 28.02.2017 / 12:50
3
answers

synchronized enumerated

Suppose a scenario in which two enumerated must be synchronized: // Este enumerado necesita los valores porque se almacenan en la base de datos enum class Enum1 { A = 12, B = 4, C = 5, }; // Este enumerado es necesario para realizar tar...
asked by 31.03.2017 / 11:31
1
answer

Is it correct to save an object in a binary?

The following code has a class and saves an object in a binary. Traditionally, a struct is made that will store the int attribute in the binary. But the code as it is works. My question is, can a code like that be used? Is it "legal"? It can be...
asked by 31.12.2018 / 00:26
1
answer

Doubt about SFINAE

How the compiler resolves the case in which it can substitute more than one template and does not give ambiguity using the SFINAE principle. #include <stdio.h> #include <iostream> template<typename T, typename U> U cast(T x)...
asked by 09.10.2018 / 15:52
1
answer

Avoid temporary copies in call to lambdas

I have the following class: class Utf8Writer { struct ZoneData { uint32_t begin; // codepoint inicial. uint32_t end; // codepoint final. }; const ZoneData *findCodepoint( uint32_t cp, FontId fid ); }; const ZoneData *Utf8Writer...
asked by 14.05.2018 / 11:15
3
answers

How to fix the error [Warning] multi-character character constant [-Wmultichar] in C ++

I'm starting to make a program in C ++ from a store, but it marks the error [Warning] multi-character character constant [-Wmultichar] in the part that I marked with *** : main () { int Coke, Sabritas, Pepsi, Gamesa, marca, Ma...
asked by 23.03.2018 / 04:18
2
answers

Doubt about the class vector

In an array the name of the array is a pointer to the array. So in iArray and &iArray[0] you get the same value. What I do not understand very well, is that it is happening when I try to repeat this same with myvector ....
asked by 10.05.2018 / 00:58
2
answers

Does not C ++ work well?

I have not played c ++ for a long time and I have forgotten so much that maybe the doubt I have or the possible failure is really something basic in the language. I have written a small code to test the overhead of the delete operator in c ++...
asked by 29.08.2018 / 21:02
3
answers

What is the difference between rand and srand?

I would like if you could explain to me what the difference is, I am very confused with rand and srand, what is the difference? I've searched elsewhere, but I confuse more. Thanks.     
asked by 22.07.2018 / 02:52