Questions tagged as 'c++'

1
answer

comparison of containers

The following code works fine - > std::vector<int> vec = { 1, 2, 3, 4, 5 }; std::vector<int> mec = { 1, 2, 3, 4, 5 }; if (vec == mec) { std::cout << "true" << std::endl; } there is an overload of the ==...
asked by 14.04.2018 / 08:03
2
answers

Use extra space beyond what is reserved by "malloc"

When we request a quantity of memory to the system and we use much more than the requested what happens? I did this test and the code here compiled normally. At first it worked as it should, I wanted to know what this implies, I believe that...
asked by 09.04.2018 / 23:03
2
answers

Can I replace cout and printf? [duplicate]

What is the difference between cout and printf ? I learned using printf and scanf , but in an online course I see the teacher using cout and some pages also use cout , but others use printf ......
asked by 16.12.2017 / 00:45
1
answer

Pointers of non-existent classes in C ++, how does it work?

Sometimes I run into situations like this: #ifndef CRIARVENDA_H #define CRIARVENDA_H #include <QDialog> #include "cliente.h" namespace Ui { class CriarVenda; } class CriarVenda : public QDialog { Q_OBJECT public: explicit Cri...
asked by 18.12.2017 / 18:39
1
answer

validating only .com.br regex

Personnel was modifying a regex to validate only specific domains that end with yahoo.com.br, terra.com.br, bol.com.br, hotmail.com.br. So gmail.com, or Provider.net.br would be invalid. Then I made the regex below: const std::regex pattern...
asked by 17.12.2017 / 05:27
1
answer

Doubt with the ternary operator [duplicate]

What does the following expression mean: struct Node *temp = root->left ? root->left : root->right; I am in doubt if he is checking for the root->left pointer or comparing *temp with root->left , in whic...
asked by 12.12.2017 / 22:10
1
answer

Create an algorithm that saves the data in HD

I created a simple calendar to record a user's contacts, but the teacher asked for the data to be saved in HD to preserve the contacts even after turning off the computer. I have to write all the code using the file properties I'm looking for...
asked by 30.11.2017 / 18:19
1
answer

Error in the average calculation of a student record

printf("Nota 1: "); scanf("%.1f", &alu[n].not1); printf("Nota 2: "); scanf("%.1f", &alu[n].not2); alu[n].media = (alu[n].not1+alu[n].not2)/2; // o erro acontece NESSA LINHA    invalid operands to binary + (have 'float *' and 'float *'...
asked by 02.11.2017 / 21:40
2
answers

The semantic difference of "Malloc" and Calloc "

I was in the programming class with C and I was wondering about the difference between Malloc and Calloc , but not in what each one does, but in the meaning of "M" and "C". I know that Malloc comes from memory al...
asked by 01.11.2017 / 12:22
1
answer

How to include header and cpp without resulting in LNK2005 error in Visual Studio

The source code below is an abstraction of a code in production. But it is real, and the facts reported below apply to it. The code compiles normally in GCG (linux), but in Visual Studio 2017 (windows), I get the error:    LNK2005 "publ...
asked by 01.10.2017 / 07:30