Skip to main content

All Questions

Tagged with
0 votes
1 answer
86 views

Is this a standard conforming way for selective constructor "inheritance"?

In trying to inherit constructors selectively (ie just some of them) I found a way that seem to work with GCC: #include <string> #include <iostream> struct B { B() { ...
skyking's user avatar
  • 14.3k
0 votes
2 answers
36 views

Issue calling a variadic template constructor

The following code doesn't work, it fails because it cannot find a constructor with a <int, bool> signature. I know can't specify explicitely the template parameters in the case of a constructor....
galinette's user avatar
  • 9,252
1 vote
1 answer
25 views

Got "expected type specifier" error while instantiating my property

My goal is to create nullable value which takes both a default value function and a key to retrieve a potential customization of the value from the flash storage. But trying to instantiate it as a ...
Stéphane de Luca's user avatar
1 vote
1 answer
299 views

How to understand implicitly declared in the right way?

As per the document, which says that the constructor, deconstructor and asignment operator of std::array are implicitly declared. How to understand that? I fully understand default declared functions(...
John's user avatar
  • 3,424
-1 votes
1 answer
105 views

template specialization of unique_ptr generating member function

I am trying to make comm class with template variable. My colleague ask me to use std::unique_ptr for memory management. But I think I failed to implement polymorphysm. I wrote code as the following. ...
jaewook kim's user avatar
-2 votes
1 answer
69 views

C++ variable initializes even though the copy constructor is deleted

The code below works unexpectedly! class CameraBuffer; class CameraBufferAccessor{ friend CameraBuffer; private: CameraBufferAccessor(const int &data, const int &mutex); public: ...
SᴀQɪB M's user avatar
0 votes
1 answer
39 views

The compiler creates a constructor of N args when I have N public member variables and no private ones. What is happening here?

The following code compiles and runs as expected, unless I uncomment one of the two commented out lines that I have labelled with "prevents compilation": #include <string> #include <...
Will's user avatar
  • 1,719
0 votes
0 answers
56 views

How do I connect three of these functions without using the constructor delegation method?

#include <iostream> #include <string> using namespace std; class Instructor{ private: string first_name; string last_name; string office_number; public: ...
Qy Ang's user avatar
  • 1
0 votes
0 answers
541 views

[COVERITY][C++] Non-static class member "A._M_elems" is not initialized in this constructor nor in any functions that it calls

I am having an issue with a coverity warning that occurs in the constructor of my C++11 class. In the class Model, I define the type Trajectory and declare it privately. template<unsigned int T, ...
Pietro Campolucci's user avatar
0 votes
1 answer
137 views

C++11: passing a temp object to a ctor, doesn't call move constructor, why? [duplicate]

I was trying to see why move constructor is called, as below: #include<iostream> #include<utility> using namespace std; struct M{ M(){cout<<"ctor\n";} M(const M&m){...
Troskyvs's user avatar
  • 8,007
0 votes
1 answer
322 views

Provide definition of constructor template outside a class template [duplicate]

Consider the following class template with a constructor template: template <class T> class C{ public: T val_; std::string str_; template <typename S> C(const S&...
aydwi's user avatar
  • 25
0 votes
1 answer
54 views

copy constructor called in the constructor

If I have the classes: #include <cstddef> #include "connection.h" class Request{ private: size_t sz; char *data; Connection *connection; public: Request(const char* d, ...
Fabio's user avatar
  • 61
0 votes
4 answers
731 views

C++ Child Class Change Parent Class's Constructor

Modified the question a bit, thanks for your help on this! Is there a way to change Parent's constructor(e.g. change the value of protected field) when initialize the Child class. For example, I have ...
PepperGooooo's user avatar
-1 votes
2 answers
756 views

Is a default constructor called on a class member variable if I am explicitly constructing it in the class constructor in c++?

So if I have something like the following: class MyClass{ public: MyClass(){ // do other stuff *oc = OtherClass(params); } private: OtherClass* ...
user avatar
5 votes
1 answer
194 views

Is it meaningful\suitable to mark the derived class as movable while the base class is non-moveable?

Is it meaningful\suitable to mark the derived class as movable while the base class is non-moveable? I know this kind of inconsistency is legal in C++, but is it meaningful\suitable in practise? In ...
John's user avatar
  • 3,424

15 30 50 per page
1
2 3 4 5
53