Questions tagged [object-construction]

For questions related to object construction, usually in an OOP environment.

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.

95 questions
0
votes
0 answers

Getters returning undefined for all properties except for those of the last element in an array

I'm using a map with key: password, value: Guest object to store guest information in my program. At the end of my program I pass an array of the guest Objects to a function to write to my txt file: writeToGuestStore('./inputFiles/guestStore.txt',…
eth4n-e
  • 1
  • 1
0
votes
1 answer

Python Factory Method Suggestions

I would like to ask you to help me out with my factory method. I have to handle multiple and periodic csv objects, each of which has its own properties, thus its own class. The only way I can tell Python one csv differs from another, is due to the…
Marco
  • 47
  • 5
0
votes
3 answers

object Object being written

I am very new to JS and am playing around trying to output this verify function I came across below. In my limited thinking I thought that the result would be false and I would be able to write that using document.write(), however it just writes…
0
votes
2 answers

The value returned for a newly constructed object returns the value of the previously created one

I have the following challenge for practicing OOP in javascript: The Bank should allow us to: Add customers A customer should be able to deposit an amount. A customer should bevable to withdraw an amount. A customer should be able see…
KN1368
  • 73
  • 4
0
votes
1 answer

Should a java constructor contain logic to build itself?

I'm working on a java project where I take in some JSON objects and have to then go through them to create a domain object that I need to then further process. Currently the constructor of this object is doing a lot of work to create an instance, it…
Astrum
  • 591
  • 3
  • 12
  • 25
0
votes
1 answer

How are objects from derived classes constructed in C++

Im not a C++ pro, i've done mostly Java and C#. A teacher said something that confused me today. I've tried to validate the info by doing some research, but i ended up even more confused. Lets say i have class A and class B. Class A is the base…
0
votes
0 answers

What is the difference between object creation and object initialization in C++?

This section of Richard Smith’s paper Guaranteed copy elision through simplified value categories makes an important distinction between object creation and object initialization (prvalues were defined in C++11 as creating temporary objects or…
Géry Ogam
  • 6,336
  • 4
  • 38
  • 67
0
votes
1 answer

Can I call the garbage collector early in matlab?

In matlab, I have a class that ties up a shared resource during construction and releases it when deleted. (In my specific case, the shared resource is a port I can interact with it via http://localhost:1234) It looks like this: classdef myClass <…
bwall
  • 984
  • 8
  • 22
0
votes
0 answers

How do I correctly construct a new Python object?

Apologies for the slightly vague question, but I'm not too sure how to word it. The following very basic code example isn't doing what I'd expect it do, and I'd like to understand why... class Message(): def __init__(self, data={}): …
Grant
  • 133
  • 7
0
votes
0 answers

Javascript examples from Duckett's book not working

I am learning javascript from Duckett's book and have noticed that the examples from the book were not working when I copied them onto my text edit. The code is on the website so, I downloaded the files and tried opening them but the same issues…
0
votes
1 answer

How to enforce that construction is always through a certain method?

I have some third-party abstract base class struct foo { virtual foo*job() = 0; ... static void* make_space(size_t sizeofDerived); }; which I cannot alter. Objects of type foo (and all derived classes) must only be created/constructed…
Walter
  • 44,150
  • 20
  • 113
  • 196
0
votes
2 answers

Reconstructing JSON with jq

I have a JSON like this (sample.json): { "sheet1": [ { "hostname": "sv001", "role": "web", "ip1": "172.17.0.3" }, { "hostname": "sv002", "role": "web", "ip1": "172.17.0.4" }, { …
asby
  • 13
  • 6
0
votes
1 answer

Lombok: How to define a special method which runs upon the Object construction?

I have a @Value @AllArgsConstructor class, and I want each instance of it to have an ID(The first object has the ID of 1, the second is 2, etc..). until now, before I used lombok but a constructor, my solution used to be: private static int…
0
votes
2 answers

Function Constructor - add function using prototype gives - Uncaught SyntaxError: Unexpected token {

I tried adding a function y() into the object constructor x using prototype chaining. It results to an unexpected error: Unexpected token { function x(a, b) { this.a = a this.b = b } x.prototype.y(){ console.log('hello') } I want…
0
votes
1 answer

QML: object instantiation

Is there a way to have a mechanism similar to Component.createObject's second argument (initial properties) with a Loader element? I'm setting the properties manually in onLoaded, but this has slightly different semantics.
pmf
  • 7,619
  • 4
  • 47
  • 77