I have an abstract base class
class AbstractClass
{
Col<AbstractClass> parent
public AbstractClass()
{
//do stuff
}
}
I have two implementations
class A : AbstractClass
{
Col<A> parent
public A(Col<A> parent)
:base(parent)
{
this.parent = parent;
}
}
class B : AbstractC...
I have a class that first needs to call the derived class constructor before it calls the base constructor. I know that by the following code the base constructor will be called first
public class A {
protected A () {
//do something
}
}
public class B : A {
public B () : base() {
//do something else
}...
I'm trying to create new objects and add them to a list of objects using boost::bind. For example.
struct Stuff {int some_member;};
struct Object{
Object(int n);
};
....
list<Stuff> a;
list<Object> objs;
....
transform(a.begin(),a.end(),back_inserter(objs),
boost::bind(Object,
boost::bind(&Stuff::some_member,_1)
)
);
...
I have a wcf service. The service itself (class that inherits the ServiceContract) has a constructor that sometimes throws exceptions. I want to present the user a message if the service fails. Should I use faults like I would for a service method?
...
Hi all,
I have a class called ArionFileExtractor in a .java file of the same name.
public class ArionFileExtractor {
public String ArionFileExtractor (String fName, String startText, String endText) {
String afExtract = "";
// Extract string from fName into afExtract in code I won't show here
return afExtract;
}
Howeve...
If one can prevent subclassing by declaring private constructor in the base class, why do we need "sealed" keyword? Is it so because CLI can optimize it better? maybe.
Thanks.
...
Hi, this question derives from my previous thread
Play mp3 from internet without FileOpenDialog
I really hope someone knows anything about this. I was told to use a WebRequest to start a download stream and then play the stream instead of playing a locally stored file.
However, trying to use the code from PlayMp3FromUrl gives me this e...
this compiles :-)
string name;
name = 1;
this does not:
string name = 1;
any thoughts?
I know that this is wrong. . . that is not the point. The first gives a smiley face.
...
I'm trying to port a
int a[][]
from Java to C++. I'm using this class as a container ArrayRef for ints because it handles references, and the project uses it extensively. In the AbstractReader class I declared
const ArrayRef<int> START_END_PATTERN_;
const ArrayRef<int> MIDDLE_PATTERN_;
const ArrayRef<ArrayRef<int> > L_PATTERNS_;
co...
Are constructors allowed to throw exceptions?
...
class A{
A(int x){}
}
class B extends A{
B(int x){}
public static void main(String args[]){
B b = new B(10);
}
}
I understand this would throw an error (one-arg constructor for B, implicitly calls super(), whereby no default-arg constructor exists for A). I am curious why one-arg constructor for B, does not...
How can I call a function and keep my constructor private? If I make the class static, I need to declare an object name which the compiler uses to call the constructor, which it cannot if the constructor is private (also the object would be extraneous). Here is the code I am attempting to use (it is not compilable):
I want to keep the ...
why isnt my object being created?
When I do it like so, I am told error C2065: 'AllReferrals' : undeclared identifier
as well as error C2228: left of '.push_back' must have class/struct/union.
If I put the list initialization before the class I get error C2065: 'AllReferrals' : undeclared identifier.
Thanks!
#include <iostream>
#inclu...
I have a UserControl that has a BaseClass object as a public member. Right now I'm doing the following to discern between which type of object I need to instantiate:
Public WithEvents theForm As OrderForm
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
Select Case Form
Case...
I'm trying to test a very simple form that uses only a list and a create. This is the controller:
public class PositionsController : Controller
{
private readonly IPositionRepository _positions;
// default constructor
public PositionsController()
{
_positions = new TestPositionRepository();
}
// DI cons...
I am absolute clueless why the following code keeps throwing NullpointerExceptions. I was not able to understand or debug this (its stripped down code from a larger class)...
The code is based on the "Enum Pattern" and I want to keep a List/Map of all "Constants" that are contained in the class (I might be using Reflection for this but ...
What I'm looking right now is a set of classes derived from a common base class. Most, but not all, of the classes require some input parameters which are obtained through modal dialogs. Those dialogs are set up and executed in the constructor of the classes. As long as the dialog isn't finished, the object isn't constructed completely. ...
To use a contrived example in Java, here's the code:
enum Commands{
Save("S");
File("F");
private String shortCut;
private Commands(String shortCut){ this.shortCut = shortCut; }
public String getShortCut(){ return shortCut; }
}
I have the following test/driver code:
public static void main(String args[]){
System.ou...
Reading some questions here on SO about conversion operators and constructors got me thinking about the interaction between them, namely when there is an 'ambiguous' call. Consider the following code:
class A;
class B {
public:
B(){}
B(const A&) //conversion constructor
{
cout << "cal...
I'm using the Boost Parameter tutorial to create a named-parameter constructor for a playing card generator. The tutorial says to put the ArgumentPack into a base class, but I want to modify variables in the card generator class. I've thought about doing this:
class CGconstructor_base {
public:
template<class ArgumentPack>
C...