Hi, suppose a C++ class has several constructors which are overloaded according the number and type and sequences of their respective parameters, for example, constructor(int x, int y) and constructor(float x, float y, float z), I think these two are overloaded methods, which one to use depends on the parameters, right? So then in python...
Hi guys, i was wonderinf if you could help me out..
I have two classes, one extends the other.. Class B will be extended by various different objects and used for common database interactions.. Now i would like class B to handle its connect and disconnects without direction from class A or any external input..
The problem from what i ...
Hi!
I want to call the constructor;
class anAbstractClass
{
public: anAbstractClass(inputdatatype){/*blablabla*/}
};
class aChield : public anAbstactClass
{
/*
...
*/
}
void _engine::initShader(_anAbstractClass** inShader)
{
*inShader = new /*???*/(inputdata for the construcor)
}
aChield* theChield;
_engine* myEngine = new _engi...
I'm having trouble with some objects in processing.
the code should have two objects displayed and moving. but i only see one object displayed and moving. maybe there's something i'm missing. check out the code.
Rule myRule;
Rule myRule1;
void setup() {
size(200,200);
smooth();
//Initialize rule objects
myRule = new Rule(0,100...
Hi everybody!
Edit:
Note that my final purpose here is not having the class working, is just learning more about templates :-)
Suppose you have a template class which implements a vector:
template <typename T>
class Vector
{
public:
Vector(size_t dim) {
dimension = dim;
elements = new T[dim];
...
I have some rudimentary question about inheritance in C#.
I have two classes. I want the child class to inherit all members of the base class (e.g. x and y), but it seems to use inheritance I should initialize the base constructor. If I define another x and y in child class so that i later initialize the base constructor so what is the ...
Should every Java class have a zero-argument constructor?
...
I'm currently using the Mootools Element constructor method to dynamically add a new row into a table.
function newPermission(somedata) {
var newUserPerm = new Element('tr', {
'html': '<td>foo</td><td>bar</td>'
});
newUserPerm.inject('permissions_table');
}
However, upon checking the resulting code, the following H...
Hi,
is there a (practicable) way to by-pass the normal (virtual) constructor calling order? (Hard to describe in one sentence, see the)
Example:
class A
{
const int i;
public:
A()
: i(0)
{ cout << "calling A()" << endl; }
A(int p)
: i(p)
{ cout << "calling A(int)" << endl; }
};
class B
: public...
I have two constructors
MyObj(String s){ //first constructor
...
if(s==null) s = somecode;
this.s = s;
...
}
MyObj(): this(null) { } //second constructor
In this way, if the empty constructor is called, it will redirect to the first constructor and initialise the value as determined by some code.
However, now...
Is this possible? For example if i write
Car myCar;
Then the constructor taking no arguments of Car is called. It results in an error if there is only a constructor taking arguments.
In Java I can easily declare an object and create it later using the exact same statement as above.
...
When BinaryFormatter deserializes a stream into objects, it appears to create new objects without calling constructors.
How is it doing this? And why? Is there anything else in .NET that does this?
Here's a demo:
[Serializable]
public class Car
{
public static int constructionCount = 0;
public Car()
{
construction...
The following code gives a compilation error:
class parent {
parent(int a){}
}
class child extends parent{}
Error:
Main.java:6: cannot find symbol
symbol : constructor parent()
location: class parent
class child extends parent{}
^
1 error
I was trying to do different things and found that adding a return type to the parent cons...
Hi,
What is the problem here in this code?
It gives segmentation fault. I found value of size in vector (int *a)
is no more 3. How is this?
#include <iostream>
using namespace std;
class vector
{
int *v;
int size;
public:
vector(int m)
{
v = new int[size = m];
for(int i=0; i<size; i++)
v[i] = ...
I'm trying to get a better understanding of general practice... specifically deriving this() in a constructor. I understand that its less code, but I consider it less readable. Is it common/good practice to do it this way? Or is it better to write a second constructor that handles it specifically?
public SomeOtherStuff(string rabble)...
Hi,
For school I need to learn Java and since I'm used to C++ (like Cocoa/Objective-C) based languages, I get really frustrated on Java.
I've made a super-class (that can also be used as a base-class):
public class CellView {
public CellViewHelper helper; // CellViewHelper is just an example
public CellView() {
this.h...
Given an abstract interface and an implementation derived from that interface, where constructors are protected (creation of these objects only being available from a class factory - to implement a DI pattern), how can I make use of make_shared in the factory function?
For example:
class IInterface
{
public:
virtual void Me...
How can I throw an exception from an enum constructor? eg:
public enum RLoader {
INSTANCE;
private RLoader() throws IOException {
....
}
}
produces the error
Unhandled exception type IOException
...
I am writing the constructor for my "main" class. The first thing it does is call a method to use commons-cli to parse the command line. If the parseOptions method returns false, an error has occurred, and the constructor should exit.
I tried writing the following code
if (!parseOptions(args)) return
but the compiler complains that I...
Hi everyone!In a class there will be a constructor.If a programmer defines that then definitely it will have a body. But if we don't define it then will that constructor will have a default body in it?
...