I looked through several guides on common C ++ pointers, and I have a few questions that I tried to find answers on the Internet without any luck.
Consider the following code:
class A{
int v,u;
public:
A(){}
A(int p1, int p2): v(p1), u(p2) {}
~A(){};
};
void f()
{
shared_ptr<A> c(new A[5]);
shared_ptr<A> d(new A[5], [](A* ptr){ delete [] ptr;});
}
int main(){
f();
}
Questions:
1- Is the user deleting a MUST with an array of objects?
2- How to pass a parameter to a constructor other than the default?
3- Can a custom debugger be a free or member function? (Not lambda).
Notes:
1- Compiler flags: -std=gnu++11 -fext-numeric-literals -std=c++11 -std=c++14 "-D MS_STDLIB_BUGS=0"
2- g ++ with MinGW64 on code blocks.
3- However, I am interested to know this as a whole.
source
share