Hello,
Java does not allow multiple inheritance, meaning that a class cannot inherit from two classes, which does not have anything in common, meaning that they are not on the same inheritance path. However, a class can inherit from more classes, if these classes are super classes of the direct super class of the class. But the class in...
environment: linux, userspace-application created via g++ from a couple of C++ files
(result is an ELF)
there is a problem (SIGSEGV) when traversing the constructor list
( __CTOR_LIST__ )
(note: code called via this list is a kind of system initialisation for every class,
not the constructor-code I wrote)
when I understan...
Could you explain the difference between setting methods in the constructor and through prototype object? The following code shows these two ways of setting the methods - say_hello and say_bye both work fine:
function MessageClass() {
this.say_bye = function() { alert('see ya'); };
}
MessageClass.prototype.say_hello = function() { al...
Hello all,
Let's say we have a class, MyParent:
class MyParent
{
public:
template<namespace T>
MyParent()
{
T* Something;
}
};
And a derived class, which uses this constructor:
class MyDerived : public MyParent
{
public:
MyDerived()
: MyParent<int>()
{
}
};
Then I get a compiling error, because there's ambiguit...
Does Krzysztof's recommendation apply to constructors? If so, how do you implement it properly?
We recommend using Collection, ReadOnlyCollection, or KeyedCollection for outputs and properties and interfaces IEnumerable, ICollection, IList for inputs.
For example,
public ClassA
{
private Collection<String> strings;
publi...
What would be the best way to write a generic copy constructor function for my c# classes?
They all inherit from an abstract base class so I could use reflection to map the properties, but I'm wondering if there's a better way?
...
Can I pass "this" to a function as a pointer, from within the class constructor, and use it to point at the object's members before the constructor returns?
Is it safe to do this, so long as the accessed members are properly initialized before the function call?
As an example:
#include <iostream>
class Stuff
{
public:
static void...
My class has the following core:
class SmartDbConnection
{
private readonly IDbConnection Connection;
public SmartDbConnection(string ConnectionString)
{
if(ConnectionString.Contains("MultipleActiveResultSets=true"))
{
Connection = new SqlConnection(ConnectionString);
}
}
}
I don't want it to have "SqlConnection" hardcod...
Hi,
What do people here use C++ Abstract Base Class constructors for in the field? I am talking about pure interface classes having no data members and no non-pure virtual members.
Can anyone demonstrate any idioms which use ABC constructors in a useful way? Or is it just intrinsic to the nature of using ABCs to implement interfaces t...
I have been noticing *__construct* a lot with classes. I did a little reading and surfing the web, but I couldn't find an explanation I could understand. I am just beginning with OOP.
I was wondering if someone could give me a general what it is, and then a simple example of how it is used with php?
Thanks,
Levi
...
In C++ the following code gives a compiler error:
void destruct1 (int * item)
{
item->~int();
}
This code is nearly the same, I just typedef the int to another type and something magic happends:
typedef int myint;
void destruct2 (myint * item)
{
item->~myint();
}
Why does the second code works? Does an int gets a destructor ju...
Earlier I asked why this is considered bad:
class Example
{
public:
Example(void);
~Example(void);
void f() {}
}
int main(void)
{
Example ex(); // <<<<<< what is it called to call it like this?
return(0);
}
Now, I understand that it's creating a function prototype instead that returns a type Example. I still don't get why ...
As an example:
public class Foo {
private Foo() {}
}
public class Bar extends Foo {
private Bar() {}
static public doSomething() {
}
}
That's a compilation error right there. A class needs to, at least, implicitly call its superclass's default constructor, which in this case is isn't visible in Foo.
Can I call Objec...
First some background:
VB.NET 2005 Application that accesses a MS-SQL back-end, using multiple Web Services for data gathering/publishing.
On to the error:
Our application mysteriously crashes on one of our clients computers, it works fine on the other computers in their office, but not on the big whigs' computer, which now makes it my...
How can I get WCF to allow the following?
Dim EmployeeID as Integer = 10
Dim emp As New WcfServiceLibrary1.Employee(EmployeeID)
Response.write (emp.LastName)
Currently I have to do this because I can't figure out a way for WCF to allow for Parameterized Constructors:
Dim EmployeeID as Integer = 10
Dim emp As New WcfServiceLibrary1.Em...
In C# I want to communicate to the calling method that the parameters passed to an object have caused its instantiation to fail.
// okay
Banana banana1 = new Banana("green");
// fail
Banana banana2 = new Banana("red");
Throw an exception? If so how?
...
The .Net C# offers two (well four) constructors:
Regex(String)
Regex(String,RegexOptions)
The first constructs a regular expression with default options, while the second gives you somewhat more control. Take a peak under the hood with Reflector shows that the first constructor calls the second with a RegexOptions.None as second para...
I'm studying ICT. One of my courses is C# and another is Physics.
Our Physics teacher used Visual Studio to animate some movements gave us some of the code he used to do it. He told us to look it up. Here's something I don't recognize:
public static Vector operator + (Vector v1, Vector v2)
{
return new Vector(v1.X + v2.X, v1.Y + v2....
I was always curious is there any possibility to overload function literal, something like you can do with Function:
var test=Function;
Function=function(arg)
{
alert('test');
return test(arg);
}
var b=Function("alert('a')");
var c=Function("alert('x')");
b();
c();
Of course you can guess that this is nice way of debuggin...
I have two classes declared like this:
class Object1
{
protected ulong guid;
protected uint type;
public Object1(ulong Guid, uint Type)
{
this.guid = Guid;
this.type = Type
}
// other details omitted
}
class Object2 : Object1
{
// details omitted
}
In the client code, I want to be able to ...