Questions tagged as 'c++11'

1
answer

Singleton and static member

Good morning, I do not understand the following line of code: Boss* Boss::s_bossInstance = nullptr; s_bossInstance is a private property of class Boss , then, 1. How is it possible that I can access it outside the same class...
asked by 09.10.2017 / 17:39
2
answers

Is std :: function equivalent to a pointer?

I was practicing with lambdas and I found the following code: auto make_fibo() { return [](int n) { std::function<int(int)> recurse; recurse = [&](int n){ return (n<=2)? 1 : recurse(n-1) + recurse(n-2); };...
asked by 05.11.2015 / 01:26
1
answer

memset does not work with large numbers

I have the following simple code: #include <bits/stdc++.h> #define oo 0xffffff using namespace std; int main() { int v[10]; memset(v, oo, sizeof(v)); for(int i = 0; i < 10; i++) cout << v[i] << endl;...
asked by 30.10.2017 / 18:50
2
answers

Detect, in the destructor, if we are a temporary instance

I'm trying to detect, in the destructor , if I'm in a temporary instance or not. The first thing I tried was to qualify the destroyers: ~S( ) & { ... } ~S( ) && { ... } With which I got a nice error message:    error:...
asked by 11.09.2017 / 07:56
1
answer

error: type / value mismatch at argument X in template parameter list

I try to create a backpack , a template class that acts as wrapper of another, and make calls to a callable provided in one of its arguments. I would like the callable to be both a class that supports operator( ) , and a normal f...
asked by 14.09.2017 / 14:12
2
answers

Read variable character by character

I need to make a program in which you enter a number and see if within that number there is a defined number and according to that number of a different result For example I have to find if at the beginning of a number x are the digits...
asked by 13.09.2018 / 00:52
1
answer

Problem removing blanks at the end of a char type pointer *

I have a problem with this function. I'm trying to eliminate blank spaces at the end of a char * pointer. Something like this: char *ptr = "Soy un puntero dinámico y me sobran espacios al final "; With the difference that this is s...
asked by 12.06.2018 / 14:23
1
answer

Extract data without using extra variables

I want to extract a data from a class; Currently, I use an auxiliary variable for it. To work, it works ... but I was wondering if it could be done in another way, saving me the variable inside the function Envoltura::result( ) : #inc...
asked by 15.03.2018 / 21:13
1
answer

On the use of smart pointers

Suppose we have the hypothetical case where pointers are used for all types of variables. More exactly, we have the following procedure to read the elements of a one-dimensional array: void leer_arreglo(int *&v) { int *i = new int;...
asked by 13.05.2018 / 17:34
1
answer

Memory reserve with std :: vector resize

for a data structure std::vector<3Dpoint> v; with 3Dpoint : struct 3Dpoint { float x, y, z; 3Dpoint(float _x, float _y, float _z){ x = _x; y = _y; z = _z; }}; I try to resize the vector s...
asked by 11.10.2017 / 17:58