Questions tagged [new-operator]
new is a language construct that dynamically allocates memory from free store and initialises the memory using the constructor.
2,956
questions
0
votes
0
answers
16
views
can not import a Python file that was generated during the execution of the running file [closed]
I try to import a Python file that was generated during the execution of the running Python file.
But it doesn't work. It show the ModuleNotFoundError error.
import os
import sys
import numpy as np
#...
-7
votes
1
answer
48
views
Can place flower [closed]
You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in adjacent plots.
Given an integer array flowerbed containing 0's and 1's, where ...
0
votes
1
answer
52
views
Why doesn't defining global `void operator new(std::size size)` cause multiple definition link error? [duplicate]
Why doesn't defining void* operator new(std::size_t) at the global scope cause a multiple definition link error?
E.g. the code below compiles and runs, but I imagine that libstdc++ must define a ...
0
votes
0
answers
24
views
Regular Object in Spring Boot Application
How Spring boot application handles the Java Object created with the new operator.
How Spring Boot Container maintains these new created objects and how garbage collections work on these objects
On ...
0
votes
0
answers
15
views
How to change the style to a navbar item when on a specific part of my page?
I'm a new web developer (started a couple weeks ago) and I'm building my first website with Bootstrap. For this I made a sticky navbar that stays on top even if you scroll down and I want it to ...
0
votes
0
answers
11
views
The New Method for Symmetric NAT traversal
Has anyone implemented the technique found and described by the Japanees researchers for symmetric NAT traversal at The New Method for Symmetric NAT traversal ? specifically, can existing STUN servers ...
2
votes
0
answers
80
views
Javascript Object() vs new Object() for ES6
I've seen a number of questions about new Object vs new Object() or new Object() vs {}, but I'm wondering about what the difference is between Object() and new Object()? In other words, what's the ...
0
votes
0
answers
15
views
Click a button then a random hotkey and print the hotkey as text on the button [duplicate]
I have a button and I want it so when you click the button the text will change to :
Enter your button or mouseclick now.
and when the button or mouseclick is pressed/clicked it will print the hotkey ...
-2
votes
0
answers
42
views
Getting SIGSEGV when trying to std::push_back() to a list which is inside a struct and accessed through the pointer [duplicate]
I am trying to implement a n-ary tree for a project. The structure of the node is as follows, I specifically need to have the link to both the parent node and the children nodes of the said node for ...
0
votes
1
answer
55
views
Out of range exception thrown when declaring a C++ vector on the free store
I'm working on a problem from Stroustrup's PPP book, Chapter 17 - the Drill.
I keep getting out of range errors thrown and believe I may be accessing the vector m_vec incorrectly when I am ...
0
votes
0
answers
37
views
Typescript arrow function object with new key won't give any errors
In my typescript code I'm not getting any errors when I use the new keyword to create an Arrow function object. now i know according to the documentation, You can not use new keyword to create an ...
3
votes
0
answers
60
views
How to make use of the default implementation of operator new when replacing it?
In C++, the global allocation/deallocation functions (operator new and operator delete) can be 'overloaded', while such overloading is actually replacing the original ones provided by the standard ...
0
votes
0
answers
44
views
Airflow 2.6.3: [2023-08-13T06:50:44.937+0000] {manager.py:922} INFO - Login Failed for user: admin
I recently upgraded to Airflow version to 2.6.3 and experiencing login failure error. Anyone came across this error after version upgrades? Please help.
[2023-08-13T06:50:44.937+0000] {manager.py:922} ...
4
votes
1
answer
149
views
In C++, how does the delete operator actually work? (At the memory level)
I know it free memory from the heap. But how does the program know that the memory being freed (or not freed). If I have to guess, there's some kind of "available-memory-list" somewhere in ...
0
votes
2
answers
80
views
Is there a substitute for Java's new() in C? [closed]
I am trying to create a simple poker game in C and am having difficulty with getting my card structures inside of an array using a loop so that I do not have to individually create each card object ...
1
vote
1
answer
69
views
Is there a way to implement the same behaviour of the new operator calling default constructors?
I want to implement my own heap allocation function to do the same as the C++ new operator when it comes to allocating elements of a class type. My allocation function (for Windows) does not use the ...
2
votes
1
answer
110
views
Ambiguous call to operator new[] when upgrading to C++ 20
I am getting an error when compiling the following code after upgrading from C++17 to C++20 with msvc:
#include <tuple>
template <typename T>
void alloc(void* dest)
{
using ty = ...
-2
votes
2
answers
60
views
Kotlin array literal syntax like java
Just a simple question
when we will get array literal syntax in kotlin like java
var array = arrayOf<Int>(1,2,3,4,5) // current syntax
var array = {1,2,3,4,5} // new syntax
If any of you have ...
1
vote
1
answer
89
views
Does C++ guarantee a memory allocation after a successful deallocation?
Consider this example,
// x is a int* allocated previously via 'new'
delete x;
x = new int;
Does this code always guarantee a memory allocation in last line as there is definitely memory left to hold ...
0
votes
1
answer
59
views
Deleting a struct that has a class member
I have a struct:
struct holder
{
int val;
std::unordered_map<int, int> num_to_addr;
};
I dynamically allocate a struct holder:
struct holder* handle = new struct holder;
I do work and ...
0
votes
0
answers
27
views
New relic cli installation failed
installer of NR1 CLI on Windows 11 reports problem with env. path update: ”PATH not updated, new length 1192 > 1024.“
How to solve this? i am getting this issue when i am trying to install the nr1 ...
0
votes
0
answers
12
views
MSVC natstepfilter - how to exclude "operator new"?
I have custom global new operator (without any namespace):
void* operator new(size_t nSize)
{ ... }
I am trying to exclude it from debugging by using .natstepfilter file:
<StepFilter xmlns="...
-1
votes
1
answer
67
views
Difference between static and dynamic character pointer usage
Which is the significance of doing the dynamic allocation, as the same is achieved by the static allocation?
#include <iostream>
#include <cstring>
const char* Allocator()
{
const ...
2
votes
3
answers
54
views
"new operator" on bound function invoked by Method and Function
forgive my bad english...
I use new operator of the bound function in different way like
function foo() {
console.log("foo", this);
}
const obj1 = { a: 1 };
function bar() {
return foo.bind(...
0
votes
0
answers
10
views
Error: Route.get() requires a callback function but got a [object Object] due to middleware
I add some middlewares in route and got this error :
const crypto = require("crypto");
const isAuthenticated = require("../Middleware/auth.js");
const router = express.Router();
...
0
votes
0
answers
69
views
Accessing element in an object in C++ OOPS
I am learning OOPS in C++. I try to access the class data member using pointer. But it throws error.
#include <iostream>
using namespace std;
class A
{
protected:
int x;
...
0
votes
2
answers
41
views
How do I loop a string if the answer to a question isn't valid until the answer is valid -python
I am completely new to scripting and I'm practicing on learning how to script in python. I want to know how to keep looping a string until a valid answer is input. For example if the input() string ...
0
votes
1
answer
19
views
Setting email naming conventions for new user creation via google sheet apps script extension
I hope the title sums it up well.
Let me preface this question with I am not a developer. I took some basic courses on html & css in college, am tech literate compared to the general population. ...
0
votes
1
answer
34
views
PHP problem How to create a new array to store the value that is not the datetype from a object data[key] field
I have getting the data from the excel by using phpspreadsheet .I try to use the foreach loop to check whether the data with datetype is valid or not and the key question is I want to get the invalid ...
3
votes
1
answer
39
views
Python: __init__ of derived Singleton not called
I was toying around with the Singleton pattern and derivation. Specifically, I had this code:
class Singleton:
_instance = None
init_attempts = 0
def __init__(self):
self....
0
votes
0
answers
16
views
Sharepoint list items not getting updated
Recently data edited in sharepoint list not getting updated and not showed in exported file also.Issue was started to appear from last week.same list is connected to a power app also
Any solution on ...
0
votes
0
answers
71
views
How to find out if C++ memory was allocated with scalar new or array new
I am working on optimizing my smart pointer in my C++ library. The pointer has, besides from the built-in pointer and reference count, a boolean stating whether the pointer is scalar or array (i.e. it ...
2
votes
2
answers
80
views
Is it valid to assign a new memory block to a variable with a deleted pointer?
int main(){
char *Allocation;
Allocation = new char[8]; //here is out first allocation;
delete[] Allocation; //after while we delete it;
Allocation = new char[16];//then we ...
0
votes
1
answer
196
views
Does overloading the new operator in C++ redefine the operator?
When overloading the new operator in a global scope in C++, are we just redefining the original functionality? From what I understand operator and function overloading works when the overloads have ...
1
vote
1
answer
59
views
Why does CluePedia-v1.5.9-2 fail to work with Cytoscape-v3.10?
I have updated to Cytoscape-v3.10 and I have noticed that CluePedia-v1.5.9-2 does not work anymore with ClueGO-v2.5.9, despite the fact that I have installed both ClueGO and CluePedia apps in my ...
0
votes
1
answer
26
views
Invoking a deleted constructor in C++
class one: public two {
public: explicit one (specifier const& use_case);
one() = delete;
void stat(Statistic val);
};
I need to test the above mentioned public interface "void stat(...
1
vote
1
answer
62
views
javascript call function with new keyword
function outer(abc) {
this.abc = abc;
return function inner() {
this.abc = abc;
return this.abc;
}
}
In the above code I cannot intantiate outer function like below
var obj = new ...
1
vote
2
answers
48
views
Add two rows per Group. Start and end of date
My dataset contains scan times by nurses in hospital rooms. My goal is to determine how many minutes the the room was unattended.
The first thing I need to do is to create 2 new rows per room for each ...
13
votes
2
answers
310
views
new A[0]: Initialization of zero-size array with dynamic storage duration for a class with inaccessible constructor
I have a C++ concept for checking that an array of objects can be dynamically allocated:
template< class T, int N >
concept heap_constructible = requires() {
delete[] new T[N];
};
And I ...
0
votes
3
answers
101
views
Is there a way to prevent passing "new T" to my observer_ptr constructor?
I want to implement my own observer_ptr class which I want to use to indicate no ownership of a pointer. I'm wondering if it'd be possible to somehow prevent someone from using the following syntax:
...
0
votes
1
answer
37
views
I created a SQL query to INSERT INTO and keep gettting -Msg 102- Incorrect syntax near ','
I copied the table structure of Patient P to new table PatientF F. I want to use Patient P and insert rows where the PATID in Patientf F= Patient P.
Here is a shortened example of the query.
INSERT ...
1
vote
0
answers
113
views
Confuse about overloading global operator new in c++
I am really cofused about overloading global operator new in c++,In this situation,i can understand it as overload:
#include <iostream>
using namespace std;
void *operator new( size_t n, const ...
0
votes
0
answers
57
views
I made rickety tic-tac-toe game
I did the tic-tac-toe game but i know i can improve that. Can you give me some hints how to implement tie and keep playing as separate parts and what i can change. It my first code, dont blame me :(
I ...
2
votes
0
answers
30
views
calculate new x509 subject hash for value for openssl
How to calculate 8 character hash of new openssl subject hash
Old hash method is just take from first 4 binary character (8 char in hex form) of md5 subject hash and reverse it like:
...
-1
votes
1
answer
74
views
Keep object alive outside if block without using new
Sample using "new" operator:
Object_A *A = NULL;
if (some_condition) {
A = new Object_A();
/*some code*/
} else {
A = new Object_A_Child();
/*some other code*/
}
/* some code which ...
6
votes
1
answer
225
views
What came first, the destructor or delete() ? C++
Many answers on this site mentions that delete() calls destructor. But the sample code below seems to call delete() inside the destructor. What is the correct usage of delete() when object is ...
2
votes
1
answer
233
views
Override __new__ of a class which extends Enum
A class Message extends Enum to add some logic. The two important parameters are verbose level and message string, with other optional messages (*args). Another class MessageError is a special form of ...
0
votes
0
answers
27
views
VBA Runtime Error 438 at newWorkbook.Worksheets(1).Range("B2").Paste, can't figure out why [duplicate]
Keep getting the error as said above at the line newWorkbook.Worksheets(1).Range("B2").Paste however this works newWorkbook.Worksheets(1).Paste
Sub CopyVisibleCellsExport()
Dim ...
0
votes
1
answer
25
views
Identical **kwargs, but one raising "cannot convert dictionary update sequence element #0 to a sequence"
I have a very weird issue with dict inheritance. I want to be able to pass custom objects in an instance of the dict object, so I made a custom __new__ method to format these objects so they are ...
0
votes
0
answers
39
views
Issues with TfidifVecotorizer() for fake news project
I am following Dataflair for a fake news project and using Jupyter notebook. I am following along the code that is provided and have been able to fix some errors but I am having an issue with the ...