Bad allocation exceptions in C++?

In a school project of mine I was requested to create a program not using STL. In the program I use alot of Poin...

Conversion from 'myItem*' to non-scalar type 'myItem' requested?

I have this C++ code: #include <iostream> using namespace std; struct MyItem { int value; MyItem* nextIte...

In what cases do I use malloc and/or new??

I see in C++ there are multiple ways to allocate and free data and I understand that when you call malloc you should...

Java FileOutputStream Create File if not exists?

Is there a way to use FileOutputStream in a way that if a file (String filename) does not exist, then it will create...

Is delete this allowed??

Is it allowed to delete this; if the delete-statement is the last statement that will be executed on that instance o...

What is the 'new' keyword in JavaScript??

The new keyword in JavaScript can be quite confusing when it is first encountered, as people tend to think that Java...

Deleting an object in C++?

Here is a sample code that I have: void test() { Object1 *obj = new Object1(); . . . delete obj; } ...

How to dynamically allocate arrays in C++?

I know how to dynamically allocate space for an array in C. It can be done as follows: L = (int*)malloc(mid*sizeof(...

Print in new line, java?

I have following code : System.out.println(" | 1 2 3 4 5 6 7 8 9"); System.out.println("-----------...

In Ruby, what's the relationship between 'new' and 'initialize'? How to return nil while initializing??

What I want is: obj = Foo.new(0) # => nil or false This doesn't work: class Foo def initialize(val) re...

Expression must have class type?

I have't coded in c++ for some time and I got stuck when I tried to compile this simple snippet: class A { public...

Difference between new and override?

Wondering what the difference is between the following: Case 1: Base Class public void DoIt(); Case 1: Inherited...

creating an array of object pointers C++?

I want to create an array that holds pointers to many object, but I don't know in advance the number of objects I'l...