I didn't imagine that I would encounter radically new syntax in Java anymore at this stage, but lo and behold, I just encountered something:
The exact context and what the code below should do is pretty irrelevant - it's there just to give some kind of context.
I'm trying to synthetically create an event in IT Mill Toolkit, so I wrote ...
I have the following question. Which one of these is better that should be followed and why?
string strMyString = "SampleString";
or
string strMyString("SampleString");
Thanks in advance.
...
Newbie Java question. Say I have:
public class Car{
...
}
public class Truck extends Car{
...
}
Suppose I already have a Car object, how do I create a new Truck object from this Car object, so that all the values of the Car object is copied into my new Truck object?
Ideally I could do something like this:
Car c = new Car();
/* ....
Hi,
I'm compiling and linking a cpp file against a pre-compiled library, and I'm getting an "undefined reference" error.
Firstly, this is the command (the library in question is quicknet3, the program I'm compiling is trapper):
g++ -w -g -I. -g -O3 -pipe -Wall -I/home/install/x86_64/include/quicknet3 -L/home/install/x86_64/lib -lqui...
Hi All,
Can you tell me why the following code is giving me the following error - call of overloaded "C(int)" is ambiguous
I would think that since C(char x) is private, only the C(float) ctor is visible from outside and that should be called by converting int to float.
But that's not the case.
class C
{
C(char x)
{
}
p...
When defining bindings for types that requires ctor arguments for the default instance it's pretty clear how to do it. However, when I want to create alternative profiles it gets a bit more difficult.
This is how it's done for a default instance:
ForRequestedType(typeof (IRepository<>))
.TheDefaultIsConcreteType(typeof (SpRepositor...
I am writing a python platform for the simulation of distributed sensor swarms. The idea being that the end user can write a custom Node consisting of the SensorNode behaviour (communication, logging, etc) as well as implementing a number of different sensors.
The example below briefly demonstrates the concept.
#prewritten
class Sensor...
What is the order in which the destructors and the constructors are called in C++? Using the examples of some Base classes and Derived Classes
...
I'm writing a program under MS Visual C++ 6.0 (yes, I know it's ancient, no there's nothing I can do to upgrade). I'm seeing some behavior that I think is really weird. I have a class with two constructors defined like this:
class MyClass
{
public:
explicit MyClass(bool bAbsolute = true, bool bLocation = false) : m_bAbsolute(bAbso...
If I have a class with two constructors like so
class Foo
{
pubic Foo(string name)
{...}
public Foo(Bar bar): base(bar.name)
{...}
}
is there some way that I can check if bar is null before I get a null reference exception?
...
I understand copy constructor is called on three instances
When instantiating one object and initializing it with values from another object (as in the example above).
When passing an object by value.
3. When an object is returned from a function by value.
I have question with no.3
if copy constructor is called when an object value...
Is there a solution to use a final variable in a Java constructor?
The problem, if I init. a final var. like:
private final String name = "a name";
then I cannot use it in the constructor, while java first runs the constructor an then the fields... Is there a solution to get in contact with the final var. in the constructor?
...
I'm creating a MovieClip subclass (let's call it MyClip) that I want to use for several library assets. I'll be instantiating these movie clips from ActionScript code. MyClip has a constructor parameter that allows it to set the initial values of certain properties.
Since I want to use it for multiple library assets, the logical way to ...
Can anyone explain why the following code does not compile (on g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-49))?
struct X {
public:
enum State { A, B, C };
X(State s) {}
};
int main()
{
X(X::A);
}
The message I get is:
jjj.cpp: In function 'int main()':
jjj.cpp:10: 'X X::A' is not a static member of 'struct X'
jjj.cpp:10...
Hi,
Say you are creating a java object like so:
SomeClass someObject = null;
someObject = new SomeClass();
At what point does the someObject become non-null? Is it before the SomeClass() constructor runs or after?
To clarify a little, say if another thread was to check if someObject was null while the SomeClass() constructor was hal...
I was wondering if anyone knew of a particular reason (other than purely stylistic) why the following languages these syntaxes to initiate a class?
Python:
class MyClass:
def __init__(self):
x = MyClass()
Ruby:
class AnotherClass
def initialize()
end
end
x = AnotherClass.new()
I can't understand why the syntax used f...
Given my code below, is there a way that the first WebTestingApp constructor can call the second before returning the new instance? I want to set some readonly fields in the constructor and, short of copy/pasting, I can't see how I can.
I feel that the answer will have something to do with constructor chaining, but I can't figure out ho...
I was curious what is the scope of variables declared inside a class constructor which are not data members of that class?
For example, if a constructor needs an iterating int i, will this variable be destroyed after the constructor finishes, or is it then global for the program?
Thanks!
...
I have a hierarchy of classes. The base class uses some tuning parameters that are loadable from file (and reloadable during runtime). Each derived class may add some additional parameters. I am looking for a way to allocate a correctly sized parameters array in the base constructor, so that I don't have to deallocate and reallocate ...
I'm building a wrapper for a jquery plugin to C# and I dont like the usage of [Optional] because its not as "optional" as it says it is(meaning you still have to declare that System.Missing library) so I decided to use overloaded methods. I want to give the user alot of customization but I'm not sure how explicit I should be with my over...