Questions tagged [construction]

Use for questions related to building a data structure, such as a heap.

Construction is a concept of Object-Oriented languages.

Objects need to be setup for use:

  • Their member variables need to be allocated
  • Any Object member variables also need to be constructed
  • The Object methods need to be setup for calling

This process is accomplished by construction.

112 questions
3
votes
2 answers

Multiple factory methods versus single method

Is it better to use a single factory method and a general constructor for all instances, then populate the instances? OR should multiple factory methods and constructors be used instead? What are the advantages to each approach? For example (Option…
Jose Cifuentes
  • 596
  • 6
  • 21
3
votes
1 answer

STL: Initializing a container with an unconstructed stateful comparator

This has been running through my mind as a possible solution to an issue, however as it is a fairly obvious technical violation of something in C++, I wanted to know how likely to it is to fail, whether there is another fairly obvious approach, etc.…
3
votes
5 answers

When is an object in Javascript constructed?

Consider the following Javascript function (1): function setData(domElement) { domElement.myDataProperty = { 'suppose': 'this', 'object': 'is', 'static': 'and', 'pretty': 'big' }; }; Now what I don't like about this function is…
Tim Molendijk
  • 1,016
  • 1
  • 10
  • 14
2
votes
1 answer

Haskell fast construction of vector from input of space separated ints

If I expect a string with space separated ints from user input (number of expected int's known), I can transfer it in haskell Data.Vector like this: main = do n <- readLn -- this is number of ints l' <- getLine let a…
Evg
  • 2,978
  • 5
  • 43
  • 58
2
votes
2 answers

In place constrution of member variable via constructor

Take the following class: template class Message { public: Message(const TPayload& payload) : m_header(sizeof(TPayload)), m_payload(payload) {} private: const Header …
Graeme
  • 4,514
  • 5
  • 43
  • 71
2
votes
2 answers

Prolog; if and (stopping) recursion

In trying to better understand prolog, lists and recursion as a whole I'm working my way through various simple tasks I've assigned to myself. Among others is removing double entries from a list. I've defined a rule: is_on(Item, [Ah|At]) :- Ah =…
Oxymoron
  • 1,382
  • 4
  • 20
  • 40
2
votes
1 answer

Construct incorrect URLs in java with java.net.URL?

Using oracle java 1.8.0_25 I have the following construct URL url = new URL(new URL(new URL("http://localhost:4567/"), "123"), "asd") According the documentation in https://docs.oracle.com/javase/tutorial/networking/urls/creatingUrls.html it should…
George
  • 7,206
  • 8
  • 33
  • 42
2
votes
2 answers

./configure--with-boost no such file or directory

When I used ./configure the terminal returned: checking for Boost headers version >= 1.41.0... no configure: error: cannot find Boost headers version >= 1.41.0 So i used the command "./configure-with-boost=/usr/include" also but it only returns…
tv49
  • 79
  • 2
  • 4
2
votes
3 answers

Hard-coding Fonts in DotNET

I've run into problems on numerous occasions of users not having one of the Windows Core fonts installed on their machine (Courier New, Comic Sans MS, Arial for example). Whenever I try to construct one of these it throws an error rather than…
David Rutten
  • 4,716
  • 6
  • 43
  • 72
2
votes
1 answer

What could cause the destructor of a parent to be called during construction of the child?

enter code hereI am seeing segfaults in a strange part of my code, and after using valgrind, it seemed the problem was the destructor of a parent being called during construction of the child. This is strange, so fired up gdb and indeed, I see…
pythonic metaphor
  • 10,296
  • 18
  • 68
  • 110
2
votes
1 answer

Range Construction Pattern

Given the following code import std.datetime: Clock, SysTime, Duration; SysTime[] times; const n = 3; foreach (i; 0..n) times ~= Clock.currTime; is there a simpler, perhaps functional, higher order pattern with which to achieve the same goal? A…
Nordlöw
  • 11,838
  • 10
  • 52
  • 99
2
votes
1 answer

Create mesh from point cloud

I have a set of points that need to be constructed as a set of triangular faces to form a solid mesh. I have looked at Delaunay Triangulation and none of it makes sense. Any advice on where to begin? I am not dealing with complex shapes, they…
Nick Cullen
  • 89
  • 3
  • 9
2
votes
3 answers

Can a java subclass's private final field be initialized before the super constructor completes?

I have a pair of classes looking like this; public abstract class Class1 { //... public Class1() { //... function2(); //... } protected abstract void function2(); } public class Class2 implements Class1 { …
Andrew Wyld
  • 7,133
  • 7
  • 54
  • 96
2
votes
3 answers

How to specify which columns can be returned from linq to sql query

I'm trying to only return a few columns from a linq to sql query but if I do, it throws the exception: Explicit construction of entity type 'InVision.Data.Employee' in query is not allowed Here's the code: return db.Employees.Select(e => new…
Justin
  • 17,670
  • 38
  • 132
  • 201
1
vote
2 answers

C++ const-correctness and const members

Possible Duplicate: Does const-correctness give the compiler more room for optimization? During the last few weeks, I have developed a thing for making all my non-static members const if possible in order to avoid unintended programming errors.…