Circle is a class, with public method GetDiameter().
What is the difference between the following 2 sets of code?
Qn1: Does Method 1 allocates memory for c on stack (hence no need free memory), while Method 2 allocates memory for c on heap (need manually free memory)?
Qn2: When should we use Method 1 or Method 2?
Method 1:
void Init(...
This is how my code looks like.
I want to kno why is the value in the label coming as blank or null.
I want to assign the value to username at get data and use it at the button click event.
Can some1 guide me with this and why is it happening and how to solve this issue
I don't want to use a session and static.
namespace GUI
{
p...
For example, in the OGRE3D engine, I often see things like
class_name class_name :: operator + (class_name & object)
Instead of
class_name class_name :: operator + (class_name object)
Well it's not that I prefer the second form, but is there a particular reason to use a reference in the input ? Does it has special cases where it is...
Why is this acceptable:
type SomeClass<'T> =
val mutable id : int
val mutable result : 'T
But this is not:
type SomeIface =
abstract id : int
type SomeClass<'T> =
interface SomeIface with
val mutable id : int
val mutable result : 'T
The compiler complains about my use of 'val' telling me to use 'm...
Hello All,
Firstly, this is just an Object Oriented Programming question and does not apply to any Language in particular.
This is quite embarassing for me. This incident happened @ work and I was too shy to clarify this with my colleagues as it would indicate a poor understanding of Object Oriented Programming on my part. So here is t...
I'm making a program that can access data stored inside a class. So for example I have this class:
#!/usr/bin/env python
import shelve
cur_dir = '.'
class Person:
def __init__(self, name, score, age=None, yrclass=10):
self.name = name
self.firstname = name.split()[0]
try:
self.lastname = name.sp...
I have a base class A and classes B and C are derived from it. A is an abstract class, and all three classes have a constructor that takes 2 arguments. Is it possible to make a method in the base class A like this:
A* clone() const
{
return new this.GetType(value1, value2);
}
and if the current object whose clone()-function is bei...
Hi, i want to add items to a gridview in asp.net from a custom class. The class has Properties X and Y. Does anyone know if im able to add special attributes to these properties so i can just add the class and not have to muck around?
eg..
[Column("Name")]
public string Name { get; set; }
Ideally i can then write something like..
th...
I've got an interface
interface IModule {
public function Install();
}
and some classes that implement this interface
class Module1 implements IModule {
public function Install() {
return true;
}
}
class Module2 implements IModule {
public function Install() {
return true;
}
}
...
class ModuleN ...
Here is my code.
import urllib2
import urllib
import json
from BeautifulSoup import BeautifulSoup
class parser:
"""
This class uses the Beautiful Soup library to scrape the information from
the HTML source code from Google Translate.
It also offers a way to consume the AJAX result of the translation, however
encodi...
I've faced a situation when I want to extend two parent classes, but php does not allow this.
Why I can't extend more than one class, but can implement more than one interface. What's wrong with extending many classes?
It seemed to me like a pretty obvious thing, until I got parse errors.
Is it a bad practice? If so, what are the alterna...
here is my case:
classloader A, loaded one class("Class1");
then, I changed Class1.java and compile it.
next I loaded Class1.class again by classloader B.
I want to compare these 2 classes, check whether the class meta data changed by someone.
Is there any way to compare 2 classes' definition data?
...
Hey php gurus. I'm running into some bizarre class scope problems that clearly have to do with some quirk in php. Can anyone tell me what out-of-the-ordinary situations might give the following error...
Fatal error: Cannot access self:: when no class scope is active in MyClass.php on line 5
Now, obviously if I were to use self:: outs...
I'm completely new to OOP PHP and currently reading "PHP Objects, Patterns and Practice". I needed to develop something that will generate a GeoRSS feed. This is what I have (it works perfectly, I would just like some critique as to what I could do different / more efficiently / safer):
class RSS {
public $channel_title;
public $chann...
Let's suppose I have several functions for a RPG I'm working on...
def name_of_function():
action
and wanted to implement axe class (see below) into each function without having to rewrite each class. How would I create the class as a global class. I'm not sure if I'm using the correct terminology or not on that, but please help...
Is this possible to reach? If yes, please correct my Foo declaration syntax.
class Foo (...) {
...
def /* the nameless method name implied here */ (...) : Bar = new Bar (...)
...
}
class Bar (...) {
...
}
val foo : Foo = new Foo (...)
val fooBar : Bar = foo (...)
...
For example (maybe a bit clumsy from a real life view, but just to illustrate):
"User" is a case class containing user name and id. Id can be never set manually, and a User class instance with no id set has no sense.
A UserBase class maintains users base and has a "getUser (name : String) : User" method returning a consistent User inst...
Hi all, basically I have two classes Inventory and Character. During the construct of the inventory I am trying to determine the characters gender however this just doesn't seem to be working for me at all.. I haven't really used static functions before so if somebody could point out what I'm doing wrong it would be much appreciated..
F...
Hello all,
I'm playing with pygame for the first time (and am kind of a newb about python in general), and wondering if anyone could help me with this...
I'm making a little shootem-up game and want to be able to create a class for bad guys. My thought was that the class should inherit from pygame.Surface, but that's giving me all kinds...
I'm looking for a usable numbering convention for use only with classes or individual files, like with Java's @version annotation.
Are there any? If not, how about some suggestions? To me it doesn't make sense to use traditional numbering conventions (let's say x.x.x.x) because only a tiny part of the version number would then hold any ...