Questions tagged as 'c++'

2
answers

How to format monetary values with C ++?

I would like to display values formatted as currency, with thousands and cents separators. I would like, for example, 56000/12 to have 4.666,67 . I can display 4,666.67 . Would there be any way to change . (dot) by...
asked by 30.05.2014 / 00:32
1
answer

Compensates to store the value of a struct member in local variable?

I see several programmers doing this. Instead of accessing the member of a struct directly, it copies the value to a local variable to the function and uses this variable. Is there performance gain in this? Does it matter if the struct...
asked by 09.02.2017 / 13:34
2
answers

Why does not the battery pop?

With this code, the book tells me that this does not pop the stack, but why exactly does it not bang? #include <stdio.h> int main(){ int *p; while(1){ p = new int; } }     
asked by 18.07.2017 / 22:38
1
answer

Store more than one value in a variable with &&

Can I store more than one number in a variable? For example: m= a&&b&&c&&d&&e I need to indicate which is the largest and the smallest number that the user entered, wanted a way to do this without having to t...
asked by 03.04.2018 / 16:02
1
answer

How to extend Widgets length within a QScrollArea?

I'm looking to build a question form in Qt. As there are several questions to be answered, it is necessary to allow the scrolling of the form, so I used a QScrollArea . The questions are all answered in a Likert scale, so I adjusted the...
asked by 22.08.2016 / 21:13
2
answers

How to define a method that receives a lambda expression?

I have a class similar to this and wanted the code it executed to be passed as a lambda expression. class T { public: double execute(); }; For example: T t; int a = 0, b = 1; t.execute([a,b]()->double{return (3*a + 5*b);}); What...
asked by 17.07.2016 / 22:48
1
answer

Static functions in C

I noticed that some libraries use functions and static variables, such as static int sum(lua_State *state) . This function belongs to a library that will be compiled into the Lua language. But also libraries with dlsym calls...
asked by 14.12.2016 / 05:37
1
answer

In C / C ++, what are the build directives for? When should I use them?

I came across a C code that used a compilation directive in #ifdef and I do not quite understand what it's for. I found an explanation, but it was not clear. Here's an example policy and the explanation I looked for: #ifdef <token>...
asked by 04.10.2015 / 01:22
2
answers

Sort method is not sorting correctly

I have the following code: #include <bits/stdc++.h> using namespace std; int main() { int n, cases = 1, a[3]; cin >> n; while(cases != n + 1) { cin >> a[0] >> a[1] >> a[2]; sort(a, a + 2); cout <...
asked by 08.07.2016 / 08:31
1
answer

Is there a difference between GCC C ++ and Visual Studio C ++?

I have already programmed in C ++ compiling with GCC and when I started using Visual Studio I noticed that it has support for C ++, however the implementation is geared towards the .Net platform. Is there a difference between these two versio...
asked by 02.08.2016 / 07:50