construction Questions

2

Solved

In C++, object constructors cannot be const-qualified. But - can the constructor of an object of class A know whether it's constructing a const A or a non-const A? Motivated by a fine point in the ...
Vedis asked 2/7, 2021 at 15:46

19

Solved

Can someone help explain how can building a heap be O(n) complexity? Inserting an item into a heap is O(log n), and the insert is repeated n/2 times (the remainder are leaves, and can't violate the...
Etty asked 18/3, 2012 at 3:15

1

Solved

How to in-place construct an optional aggregate? It seems I can only construct an optional single thing, and not an optional aggregate of things. #include <optional> #include <iostream>...

3

Solved

I recently started using Haskell and it will probably be for a short while. Just being asked to use it to better understand functional programming for a class I am taking at Uni. Now I have a slig...

2

Solved

I'm working with the following (simplified) factory design to create objects of some inheritance hierarchy, shouldn't be anything special: // class to create class Class { public: Class(Type type...
Boy asked 15/3, 2016 at 10:49

3

Solved

Some jquery plugin extend widget use _create method, while others use _init method, can someone explain the differences between the two? Also any guidance on when it is better to extend widget or ...
Permalloy asked 20/10, 2010 at 22:33

3

Solved

Consider the following C++ class: struct Point { int x; int y; explicit Point() =default; // 1 explicit Point(int x_, int y_): x(x_), y(y_) { } // 2 }; The second constructor is useful for ...
Blowsy asked 4/12, 2016 at 18:50

2

Solved

Shouldn't the temporary A(3) be destroyed before "Here" gets printed? #include <iostream> struct A { int a; A() { std::cout << "A()" << std::endl; } A(int a) : a(a) { std::cou...
Monophony asked 18/10, 2015 at 22:24

2

Solved

I answered a question here: https://stackoverflow.com/a/28862668/2642059 Where I needed to use recurrence to step through a string. I wanted to use a const string& as my parameter on each funct...
Shufu asked 12/3, 2015 at 10:51

2

Solved

Lately I ran into a problem which somehow (but only somehow) makes sense to me. It is based on interpreting the construction of a temporary as declaration of the single (!) constructor argument. Pl...
Alphonsoalphonsus asked 19/1, 2015 at 22:40

3

Solved

It's been rehashed over and over that primitive types don't have constructors. For example this _bar is not initialized to 0 when I call Foo(): class Foo{ int _bar; }; So obviously int() is not...
Wheaten asked 12/12, 2014 at 12:19

5

Solved

In Java, an array IS AN Object. My question is... is an Object constructor called when new arrays is being created? We would like to use this fact to instrument Object constructor with some extra b...
Erudition asked 23/1, 2009 at 22:37

1

Solved

I'm facing some strange behavior with thread_local and not sure whether I'm doing something wrong or it's a GCC bug. I have the following minimal repro scenario: #include <iostream> using n...
Adanadana asked 28/3, 2014 at 20:49

3

Solved

Is this code valid? int foo() { std::vector<std::string>& v = std::vector<std::string>(5, "X"); // Do something silly... return 42; } For some reason I thought that the temp...
Funchal asked 10/5, 2012 at 18:32

2

Solved

I'm making a simple threaded server application in C++, thing is, I use libconfig++ to parse my configuration files. Well, libconfig doesn't support multithreading, thus I'm using two wrapper class...

2

Solved

I've seen the following type mistake a couple of times while working with C++ code: QString str = str.toUpper(); This can be a fairly easy mistake to make and yet it compiles and executes (somet...
Floater asked 10/10, 2011 at 20:31

4

Solved

Say I have a class with some const reference member variable and I would like to forbid a certain type of construction. So I would declare the according constructor private. Of course, a constructo...
Buckman asked 6/9, 2011 at 9:13

4

Solved

I have a container which holds a bunch of pointers to a base class, and a function which takes some input and returns a class which is a subclass of the base class. Which subclass it returns depend...

5

Solved

I am unclear on the structure of abstract syntax trees. To go "down (forward)" in the source of the program that the AST represents, do you go right on the very top node, or do you go down? For ins...

4

Solved

I'm trying to learn a little bit more about c++ strings. consider const char* cstring = "hello"; std::string string(cstring); and std::string string("hello"); Am I correct in assuming that b...
Periapt asked 23/4, 2011 at 21:54

9

Does anyone know how to generate an HTMLDocument object programmatically in Java without resorting to generating a String externally and then using HTMLEditorKit#read to parse it? Two reasons I ask...
Veratridine asked 5/6, 2009 at 14:19
1

© 2022 - 2024 — McMap. All rights reserved.