Hi, I have a problem....
Lest say I have a class like this one:
public class A: InterfaceA
{
private FileInfo _fileInfo = null;
public A(FileInfo fileInfo)
{
this._fileInfo = fileInfo;
}
...
}
and another one:
public class B: InterfaceB
{
private A _classA = null;
public B(A classA)
{
...
I currently restruct my program to be more object-orientated and I'm having trouble with the constructors of my objects.
All objects are stored in a database which has to be human-readable, so I figured it would be nice for the programmer to pass the constructor of an object the table or datarow directly and the object would get the val...
I have a bunch of Repository classes which all look a bit like the following. Note that I have omitted certain methods; I just want you to get a flavour.
public class SuggestionRepository : ISuggestionRepository
{
private IUnitOfWork _unitOfWork;
public SuggestionRepository(IUnitOfWork unitOfWork)
{
_unitOfWork = un...
For a constructor with a single parameter, is it OK to throw an ArgumentNullException inside the constructor if the parameter is null/empty? OR, should it be thrown in the method that actually uses the argument? Thanks.
...
Hello guys!
I have constuctor (window + formPanel)
AddOrgWindowUI = Ext.extend(Ext.Window, {
title: 'Create something',
width: 400,
height: 200,
layout: 'fit',
initComponent: function() {
this.items = [
{
xtype: 'form',
id: 'add-form',
padding: 5,
initialConfig: Ext.apply(this...
I have a simple class which has a static constructor and a instance constructor. Now when i initialized the class , both static and instance constructor are called. Only static is referred once in a application domain . Can i again call the same class initialization and static constructor initialize again? I have tried but it didn't happ...
In this simple example, why do I need to make 'member' const in order to get this to compile?
struct ClassA
{
ClassA(int integer) {}
};
struct ClassB
{
ClassB(int integer):
member(integer)
{
}
const ClassA& member;
};
int main()
{
ClassB* b = new ClassB(12);
return 0;
}
Otherwise, I get this err...
I am constructing enum values that have a data structure like the following:
enum MetaType {
HUMAN(
new MetaTypeAttribute(AttributeType.BODY, 1, 6),
new MetaTypeAttribute(AttributeType.AGILITY, 1, 6),
new MetaTypeAttribute(AttributeType.REACTION, 1, 6)
),
ORK(
new MetaTypeAttribute(AttributeType.BODY, 4, 9),
new MetaTypeAtt...
I have a class
class Rational
{
private int _n;
private int _m;
public Rational(int n, int m)
{
_n = n;
_m = m;
}
}
But m should be > 0. What should I do to notify user that he enter incorrect data to constructor?
...
I wonder if can I say that a constructor is a special case of a method?
...
I have trouble implementing my class. It should be able to initialize from std::string. So I wrote a copy (?) constructor:
CVariable (std::string&, const int p_flags = 0);
I'm trying to make an object of CVariable:
MCXJS::CVariable s_var = (string)"good job";
I'm getting the following error:
F:\Projekty\MCXJS\src\main.cpp|8|error:...
Hi guys,
I've made a profiling method:
@Around("tld.mycompany.business.aspects.SystemArchitecture.inServiceLayer() && !tld.mycompany.business.aspects.SystemArchitecture.publicConstructor()")
public Object profileBusiness(ProceedingJoinPoint pjp) throws Throwable {
try {
long start = System.currentTimeMillis();
String name = pj...
Hey everyone,
I am using the __call magic within some of my mvc code to produce an autoloadable forms framework but I have ran into a problem I am hoping some one on here might have a work around for.
The __call magic takes two paramters: $methodName and $arguments. The arguments come back as an array of args which you called. Normally...
Hello =)
what is the difference between the three following constructors, and when do i use each of them. sorry for this basic question :
DuplexChannelFactory(InstanceContext)
DuplexChannelFactory(Object)
DuplexChannelFactory(Type)
http://msdn.microsoft.com/de-de/library/ms585874.aspx
Thanks!
regards
thomas
...
Look at this code:
#include <framework_i_hate.h>
int main() {
XFile file("./my_file.xxxx", "create");
XObject object("my_object");
// modify the object
object.Write();
}
Try to guess where object will be saved... yes, you guessed it. I think this is too magic, I'd like to write something like object.Save(file), but it's not n...
The whole question is in the title. For example:
enum enumTest {
TYPE1(4.5, "string1"), TYPE2(2.79, "string2");
double num;
String st;
enumTest(double num, String st) {
this.num = num;
this.st = st;
}
}
The constructor is fine with the default or private modifier, b...
I'd like to be able to test a class initialises correctly using Moq:
class ClassToTest
{
public ClassToTest()
{
Method1(@"C:\myfile.dat")
}
public virtual void Method1(string filename)
{
// mock this method
File.Create(filename);
}
}
I thought I'd be able to use the CallBase property to...
VERSION 1
class Doh {
private:
static std::map<const std::string, const Doh*> someMap;
std::string stringValue_;
public:
Doh(std::string str) : stringValue_(str) {
Doh::someMap.insert(
std::make_pair<const std::string,const Doh*>
(this->stringValue_,this)
);
}
}
The above wa...
Trying to use __construct inside a controller to assign some variable but it keeps throwing errors. Hoping that someone can lead me in the right direction.
class Controller_Mobile extends Controller {
public function __construct()
{
parent::__construct();
$iphoneDetect = strpos($_SERVER['HTTP_USER_AGENT']...
I'm trying to build an automatic testing framework (based on jUnit, but that's no important) for my student's homework. They will have to create constructors of some classes, and add them methods. Then, with the testing functions I provide, they will check if they went allright.
What I want to do is, by reflection, create a new instanc...