class

Visual Basic - returning "this" in a function call

I have a function within a class which I would like to return the class itself however "return this" appears to be invalid in VB. I am using ASP.NET v1.1 if that makes a difference? Sample (extremely simplified) code is as follows: Public Class Cart Private sItems As String Public Function addItem(ByVal itemName As String) A...

Arrays as objects

I there a method to allow me to use an array as an object? I have the following code in my main class function __construct() { require 'config.php'; $this->config = new PHPSO_Config(); } where the PHPSO_Config class looks something like this class PHPSO_Config { /** * The administrators email address */ ...

Practical usage of partial keyword in C#

I know it lets visual studio to separate WinForms UI code from the UI events, etc. But are there any practical uses for it? ...

Is there a Java package to read the UNIX /etc/group file?

I have been scouring the Internet looking for a Java package/class that will allow me to parse the UNIX /etc/group file. While it really wouldn't be so hard to write this from scratch, I'm quite surprised not to find something already out there. There is a POSIX passwd class (see http://www.bmsi.com/java/posix/docs/posix.Passwd.html), ...

Linq To SQL Without Explicit Foreign Key Relationships

I am working with a few legacy tables that have relationships, but those relationships haven't been explicitly set as primary/foreign keys. I created a .dbml file using "Linq To Sql Classes" and established the proper Case.CaseID = CaseInfo.CaseID association. My resulting class is CasesDataContext. My Tables (One to many): Case ---...

Why can't java find my method?

Hey everyone, I am trying to wrap my mind around something in java. When I pass an object to another class' method, can I not just call any methods inherent to that object class? What is the reason code such as the example below does not compile? Thank you, class a { public static void myMethod(Object myObj) { myObj.testing();...

C++: What is the size of an object of an empty class?

I was wondering what could be the size of an object of an empty class. It surely could not be 0 bytes since it should be possible to reference and point to it like any other object. But, how big is such an object? I used this small program: #include <iostream> using namespace std; class Empty {}; int main() { Empty e; cerr <<...

how to declare a record inside an OCAML class

hello, I wanna declare a record inside a class as follows: class player (x, y)= object(self) type gun = {x:int; y:int; active:bool} val guns = Array.create 5 {x=0; y=0; active=false} .... but the compiler claim that this line is syntax error : type gun = {x:in .... when declared outside the class like this type : gun...

Defining a class within a namespace

Is there a more succinct way to define a class in a namespace than this: namespace ns { class A {}; } I was hoping something like class ns::A {}; would work, but alas not. ...

C++ class best practice

I'd like to know some best practice when designing c++ classes. To put it in context, I have a c++ class named Vec3. class Vec3{ private: float elements[3]; public: Vec3(Vec3 v1){...} Vec3(int x, int y, int z){...} Vec3 add(Vec3 v1){...} Vec3 add(int x, int y, int z){...} ... Vec3 multiply(Vec3 v1){...} ...

Is it reasonable to have more than 65536 User Defined Types in large projects?

I'm thinking about some stuff related to runtime type info, and I'd like some feedback from programmers who work on much larger projects than I do. Is it at all reasonable to expect any program to ever have more than 65536 (2^16) user-defined types (classes and structs) in a single project? This does not mean 65536 instances, it means ...

How to properly name a class with respect to its namespace?

One can often see class names carrying a reference to the namespace to which they belong. One of the most popular examples is the .NET 'Xml' namespace where every single class defined in it is prefixed with the 'Xml' tag. This has always seemed pretty redundant to me, but recently I've realized that in some cases it could be useful... b...

How to implement Watir classes (e.g. PageContainer)?

I'm writing a sample test with Watir where I navigate around a site with the IE class, issue queries, etc.. That works perfectly. I want to continue by using PageContainer's methods on the last page I landed on. For instance, using its HTML method on that page. Now I'm new to Ruby and just started learning it for Watir. I tried asking...

Replace http:// in anchor portion of links using Jquery

Hi, on a page there a several links of: <a class="linked" href="http://link1.com&gt;http://link1.com&lt;/a&gt; <a class="linked" href="http://link2.com&gt;http://link2.com&lt;/a&gt; How would one remove the second http:// in each link so it can't be seen on the screen. I've tried this to no avail: $(document).ready(function() { $(...

UML Class diagram Relation type

I have two classes, but don't what kind of relation i should use. I have a class Document with a lot properties and no methods. The second class is what i called the DocumentFact (Fact - Factory). This class contains different methods which returns a collection of Document objects. So, the Document class doesn't know anything about the ...

How can I call a static method on a variable class?

Hi, I'm trying to make some kind of function that loads and instantiates a class from a given variable. Something like this: <?php function loadClass($class) { $sClassPath = SYSPATH."/classes/{$class}.php"; if (file_exists($sClassPath)) { require_once($sClassPath); $class = $class::getInstance(); } } ?> If I use it like...

Is it possible to have two partial classes in different assemblies represent the same class?

I have a class called 'Article' in a project called 'MyProject.Data', which acts as the data layer for my web application. I have a separate project called 'MyProject.Admin', which is a web-based admin system for viewing/editing the data, and was build using ASP.NET Dynamic Data. Basically I want to extend the Article class, using a pa...

2 classes reference each other is this ok?

if i have a class gui and a class for the logic, is holding a reference in gui to logic and logic to gui very bad? ...

pointer to objects within a class, C++ newbie question

why in C++, for objects A,B //interface, case #1 class A { B bb; } A::A() { //constructor bb = B(); } //interface, case #2 class A { B *bb; } A::A() { //constructor bb = new B(); } Why case #2 work but not #1?? Edit: I got it now. But for case #1, if an instance of A is freed, will its bb also be automatically freed? Case #2 yo...

Encapsulation within class definitions

For example, do you use accessors and mutators within your method definitions or just access the data directly? Sometimes, all the time or when in Rome? ...