delegating-constructor Questions
1
The following code compiles with g++ 14.2 and clang++ 18.1, but fails with MSVC 17.10.
class Base {
public:
using peak = Base;
Base() = default;
};
class Derived : public Base {
protected:
usin...
Outland asked 14/9, 2024 at 13:49
4
Solved
Am I doing this right? I'm trying to delegate a C++ class constructor as it's basically the same code repeating 3 times.. I read up on C++x11 and read that g++ 4.7.2 allows this but I'm not sure if...
Hydroxyl asked 19/12, 2012 at 20:56
4
Solved
[this question has been highly edited; pardon that, I've moved the edits into an answer below]
From Wikipedia (subarticle included) on C++11:
This [new delegating constructors feature] comes wi...
Oneness asked 14/10, 2015 at 2:50
2
Solved
Actually the segmentation fault happens in another program I tried to compile which happens because of this behaviour.
My question is:
This is a bug or my fault?
Reproducible in any way (even...
Unproductive asked 24/12, 2017 at 17:12
2
Solved
I have a class A with lots of data members, some of which are constant. All data members have proper copy constructors, so I want to default a copy constructor of my class:
class A
{
public:
A() ...
Awfully asked 1/8, 2017 at 8:38
3
Solved
I've got a non-trivial type that owns multiple resources. How do I construct it in an exception safe manner?
For example, here is a demo class X that holds an array of A:
#include "A.h"
class X
...
Crimpy asked 5/8, 2016 at 3:26
4
Solved
I know that there is no way to do this in pure C++, but I was wondering if it is possible to call a constructor from another constructor's initialization list in C++/CLI, same way one can do it in ...
Zahara asked 1/3, 2010 at 16:0
2
struct D
{
virtual void m() const = 0;
};
struct D1 : public virtual D { };
struct D2 : public virtual D { };
struct B : public D2
{
B() { }
B(int val) : B() { }
void m() const { }
};
str...
Merna asked 27/9, 2014 at 13:22
1
In this response, tloveless pointed out that it's possible in MSVC to use this->foo::foo(42); for constructor delegation to directly call a constructor:
#include <iostream>
struct foo
{
...
Eveliaevelin asked 28/4, 2014 at 17:26
2
Solved
i want to achieve a class like this:
class A{
int a;
int b;
int c;
A():a(),b(),c(){};
A(int ia,int ib,int ic=ia+ib):a(ia),b(ib),c(ic){}; //this is what i need
};
I want the ic's default val...
Pedigo asked 27/9, 2013 at 5:47
1
© 2022 - 2025 — McMap. All rights reserved.