I would like to check if a class type is even instantiable before attempting to instantiate it via the new keyword in javascript.
For example
var geocoder = new GClientGeocoder();
will fail if the GClientGeocoder class is not available in the namespace.
What's the javascript idiomatic way to do this?
...
I'm maintaining a plugin (implemented as a dll) for a big closed source application. This has been working fine for years. However, with the latest update to it's SDK the vendor overloaded global operators new and delete. This causes lots of trouble for me. What happens is that my plugin allocates a string. I pass this string into a stat...
We normally create objects using the new keyword, like:
Object obj = new Object();
Strings are objects, yet we do not use new to create them:
String str = "Hello World";
Why is this? Can I make a String with new?
...
When dealing with objects that require data known only at runtime, such as a username and password, where should object instantiation happen: by using new, in a factory, or in a DI container?
For example, I could just new an object once I have the data:
UserCredentials creds =
new UserCredentials(dialog.getUsername(), dialog.getPas...
I am a bit confused about the virtual/new/override thing, here's some example:
class A
{
public virtual void mVVirtual() { Console.WriteLine("A::mVVirtual"); }
}
class B : A
{
public virtual void mVVirtual() { Console.WriteLine("B::mVVirtual"); }
}
class C : B
{
public override void mVVirtual() { Console.WriteLine("C::mVVi...
How to Add a new row to a DATAGRIDVIEW in ASP.NET....using c# Code ???
...
Hello again
Yesterday I posted a question about the new/virtual/override keywords, and i learned a lot from your answers. But still i remain with some doubts.
In between all the "boxes", i lost touch with what's really happening to the type's method tables. For instance:
interface I1 { void Draw(); }
interface I2 { void Draw(); }
cla...
class Animal
{
public:
int a;
double d;
int f(){ return 25;}
};
Suppose for the code above, I try to initialize an object, by saying new Animal(), does this new() also allocate memory for the function f()?
In other words, what is the difference in memory allocation terms if I had this class instead and did a new Animal() ? :
c...
Imagine I'm in C-land, and I have
void* my_alloc(size_t size);
void* my_free(void*);
then I can go through my code and replace all calls to malloc/free with my_alloc/my_free.
How, I know that given a class Foo, I can do placement new; I can also overload the new operator. However, is there a way to do this for all my C++ classes? (...
I am trying to have people be able to open HTML widgets by clicking on a button in my Joomla page. All the widgets are different sizes. The code is entered as HTML in Jumi. Currently I have the action set to:
"On click open in new window without browser navigation."
The problem is this this always opens in a full screen size with the w...
I have a class Parent. I want to define a __new__ for Parent so it does some magic upon instantiation (for why, see footnote). I also want children classes to inherit from this and other classes to get Parent's features. The Parent's __new__ would return an instance of a subclass of the child class's bases and the Parent class.
This is ...
Possible Duplicate:
Any reason to overload global new and delete?
In what cases does it make perfect sense to overload operator new?
I heard you do it in a class that is very often allocated using new. Can you give an example?
And are there other cases where you would want to overload operator new?
Update: Thanks for all ...
I have a system that prepopulates PDF fields via XFDF.
THe XFDF code seems fine, but when I try to open it with the header() in PHP, PDF fires an error.
If I ignore it and refresh the page, it works fine and poplulates the form correctly.
Below is the XFDF code as well as the header I am using...
Any idea why PDF doesnt display it rig...
Hi,
I have a few questions regarding memory handling in C++.
What's the different with Mystruct *s = new Mystruct and Mystruct s? What happens in the memory?
Looking at this code:
struct MyStruct{
int i;
float f;
};
MyStruct *create(){
MyStruct tmp;
tmp.i = 1337;
tmp.j = .5f;
return &tmp;
}
int main(){
...
Background: I'd like to make use of Electric Fence in an MFC application. I'd like to track new/delete, and if I can track malloc/free that's an added bonus.
Unfortunately, MFC redefines new and delete - but using macros (DEBUG_NEW) - so I can't use the standard C++ method of redefining them. (MFC defines them to have different signatur...
I have a script that selects and drags several elements. It works fine but when I want to add another new element to that function, append it to DOM, it does not work. The function is:
$(function() {
var selected = $([]), offset = {top:0, left:0};
$("#selectable1").selectable();
$("#selectable1 span").draggable(...
I am learning C++ for the first time. I have no previous programming background.
In the book I have I saw this example.
#include <iostream>
using::cout;
using::endl;
int main()
{
int x = 5;
char y = char(x);
cout << x << endl;
cout << y << endl;
return 0;
}
The example makes sense: print an integer and the AS...
What is the difference between GWT.create(SomeClass.class) and new SomeClass()?
Why would you use one over the other?
...
I'm working on integrating rLog with our code base, and I'm noticing a problem on Windows that I don't have on linux. In a header file I have a static variable that gives me a "verbose" logging channel (one up from debug basically), defined thusly:
static RLogChannel *rlog_verbose = DEF_CHANNEL("verbose", Log_Debug);
There's no probl...
I've never quite understood how the argument lists for operator overloading are determined in a systematic way, and I'm particularly confused by a problem I have now.
When you overload a unary operator it has one argument, or zero if it's a class member. When you overload a binary operator it has two arguments, or one if it's a class m...