class

Object's structure overriding defined methods?

旧巷老猫 提交于 2019-12-24 14:49:18
问题 I have a class called Object : class Object { public: Vector pos; float emittance; Vector diffuse; virtual float intersection(Ray&) {}; virtual Vector getNormal(Vector&) {}; }; And another class which inherits it: class Sphere: public Object { public: float radius; virtual float intersection(Ray &ray) { Vector distance; float b, c, d; distance = ray.origin - pos; b = distance.dot(ray.direction); c = distance.dot(distance) - radius*radius; d = b*b - c; cout << -b - sqrt(d); if (d > 0.0) {

What is the best way to distribute as3 classes and packages? [closed]

三世轮回 提交于 2019-12-24 14:28:00
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I have a small framework that I would like to put out there. I would love to export these classes as a single file. I know there is a SWC format, but there is not much recent information on how to export build this and I have a feeling this format might be outdated. 回答1: A SWC file is just a ZIP file (with the

multiprocessing initialising a function in a class

て烟熏妆下的殇ゞ 提交于 2019-12-24 14:13:51
问题 I am trying to initialise a function in a class using multiprocessing, by calling it from a function, which is inside the same same class def Streaminit(self,_track): self.twitterStream = tweepy.Stream(self.auth, Twitterapi.Listener()) self.twitterStream.filter(track=_track) def Stream(self,track=""): self.streamobj = multiprocessing.Process(target = self.Streaminit(),args=(track,)) but when I call stream it raises an error TypeError: Streaminit() takes exactly 2 arguments (1 given) What am I

How to pass data from one form to another using a class (VB.Net)

纵饮孤独 提交于 2019-12-24 14:09:39
问题 In my main program (form) I have two list boxes, one text box, and a button. When I pick two items in each list boxes and enter a number in the text box, it is suppsoed to be stocked in an array. I wanted to do this using a class. (I just asked a question about this, it works well now). The problem is I want to show the results in a different form. The code in my class looks like this: Public Class Stocking Public sale(3, 4) As Integer Public numberSellers(3) As Integer Public numberProducts

Android onLocationChanged and MainActivity class

非 Y 不嫁゛ 提交于 2019-12-24 14:01:14
问题 I have the following code: public class MyLocationListener implements LocationListener { @Override public void onLocationChanged(Location loc) { // called when the listener is notified with a location update from the GPS Log.d("Latitude", Double.toString(loc.getLatitude())); Log.d("Longitude", Double.toString(loc.getLongitude())); } @Override public void onProviderDisabled(String provider) { // called when the GPS provider is turned off (user turning off the GPS on the phone) } @Override

XCode - Same classe name, two targets

試著忘記壹切 提交于 2019-12-24 13:58:02
问题 I'm trying to regroup several applications I have in the same XCode project. So I created a new XCode project and added two targets, and import the source code of my two apps in one of the targets. The problem is that I have classes with the same name in the two applications. When I compile the first one, no problem. But if I try to compile the second target, I have lots of issues like this : In file included from /Users/administrateur/Documents/Merged_iPhone_Projects/Target2/Classes

Creating new element with a dynamic extends class expression

不打扰是莪最后的温柔 提交于 2019-12-24 13:52:45
问题 Is it possible to pass a class expression as parameter? Have not tried the eval route yet.. // CardtsElements.Zone contains a valid class expression // used to create a valid Zone Custom Element let extend = (source, name, definitionClassExpression) => customElements.define('CARDTS-' + name, class extends CardtsElements[source] definitionClassExpression); ^^^^SYNTAX ERROR^^^^^^^^^^ // Create a new 'CARDTS-FOUNDATION' element extending 'CARDTS-ZONE' extend('Zone','Foundation', { static get

Sorting a list of classes alphabetically based on variable in class python 2.7

ⅰ亾dé卋堺 提交于 2019-12-24 13:29:32
问题 I was wondering if there was a way to make python 2.7 sort a list that is made up of classes alphabetically by a string inside the class. class person: #set up for patient def __init__(self, FName, LName): self.FName = FName # the first name of patient self.LName = LName # last name of patient patients=person(raw_input('first name'),raw_input('second name')) i=1 all=[patients] orderAlphabet=[patients] orderInjury=[patients] print a[0] while i<3: patients=person(raw_input('first name'),raw

Converting String into Object Python

随声附和 提交于 2019-12-24 13:24:43
问题 I've just started learning Python a couple of weeks ago, and I started writing a text-based adventure game. I'm having some trouble finding a good way to convert strings into instances of a class, other than using eval(), which I've read isn't safe. For reference, here's what I'm working with: class Room(object): """Defines a class for rooms in the game.""" def __init__(self, name, unlocked, items, description, seen): self.name = name self.unlocked = unlocked self.items = items self

Casting to String or using String.valueOf() in Java [duplicate]

Deadly 提交于 2019-12-24 13:24:15
问题 This question already has answers here : Difference between casting to String and String.valueOf (8 answers) Closed 6 years ago . This morning I found an interesting question --- cast object to string check if valid and I found there are two types of answers. One is to cast an object to String, the other one is to get the string representation of that object instead (eg. using String.valueOf() or toString()). My questions are: what is the best practice? what is the difference between them?