instantiation

proper instantiation & memory management in cocos2d-x

﹥>﹥吖頭↗ 提交于 2019-12-05 16:49:50
I've been looking for documentation for cocos2d-x but it seems to be really really poor beyond the very basics. I understand that my own classes should inherit from CCObject to be able to use (originally cocoa's) retain / release mechanism, but I'm still confused about what happens when you new something. init is not called automatically. is it OK to call it from inside the constructor? does that alone guarantee that my object will start with a reference count of 1? what is CC_SAFE_DELETE and when should I use it? do release and autorelease work exactly like in cocoa? what about CC_SYNTHESIZE

Not Understanding Object Instantiation in C#

心不动则不痛 提交于 2019-12-05 14:10:42
This post goes to a gap in my understanding of C# classes and why they are preferable to static functions. I am trying to get a List of objects. Each object in the list represents a record in a table. This would be easy to do in a static function. Using a class, I've been able to do it as follows: Calling routine: ListOfBusinesses l = new ListOfBusinesses (); List<Business> b = l.listBusinesses(); The classes: public class Business { public string Bupk { get; set; } public string Bu_name { get; set; } } public class ListOfBusinesses { public List<Business> listBusinesses() { List<Business>

Right way to instantiate class in PHP

走远了吗. 提交于 2019-12-05 11:28:28
I am trying to create a method inside class, that will instantiate class that is currently in. But I would also need that from this method to work correctly in all extended classes. As I have learned from this thread , it's not good to use self keyword for this task. So obvious choice would be using static keyword. But, I've come across different method that also works. Example: class SimpleClass { private $arg; public function __construct( $arg ){ $this->arg = $arg; } public function getArg(){return $this->arg;} public function setArg($arg){$this->arg = $arg;} public function staticInstance()

Exporting STL class from DLL - why is there no warning from the return type?

帅比萌擦擦* 提交于 2019-12-05 09:55:06
问题 My question is related to exporting a C++ class with STL inside. For example: class __declspec(dllexport) Hello { std::string name; public: std::string& getName(); void setName(const std::string& name); } Various articles seems to indicate that this is very bad , which is quite understandable. Everything must be compiled with the same compiler settings and CRT version. Otherwise everything will crash and burn. Question: What I don't understand is why only data members seem to have an issue.

Semantic correctness of non-instantiated C++ template functions

喜夏-厌秋 提交于 2019-12-05 08:55:38
The following C++ code does not compile e.g. with g++-4.7 or clang++-3.2: struct Bar {}; template<typename T> void foo(T t, Bar bar) { t.compiler_does_not_care(); bar.nonexistent_method(); } int main() {} Why do compilers check the code of the template function foo for semantic correctness (where they can) even though it is never instantiated? Is this standard compliant? quantdev Bar is a non dependent name (i.e. its type does not depend on T ), so the compiler is required to verify the correctness of the code during the first phase of name-lookup (see the note below). Since Bar has no

instantiateViewControllerWithIdentifier seems to call viewdidload

陌路散爱 提交于 2019-12-05 06:04:50
I am trying to push a ViewController programmatically into a navigation controller, And I'm using my storyboard to create it. here is my code : + (void) pushViewController:(NSString *) identifier ForItems:(NSMutableArray *) items sender:(UIViewController *) sender { GenericViewController *viewController = (GenericViewController *)[sender.storyboard instantiateViewControllerWithIdentifier:identifier]; viewController.items = [[NSMutableArray alloc] init]; [viewController.items removeAllObjects]; [viewController.items addObject:[[NSMutableArray alloc] init]]; [viewController.items[0]

Is there a way to dynamically create and dispose of Webbrowser control?

血红的双手。 提交于 2019-12-05 05:16:37
问题 I have this App that uses the Webbrowser control to do automated browsing. I need to come up with a way to automatically close the browser (dispose), then create another instance that actually works. Here's some of the code that I have so far. this.webBrowser2 = new System.Windows.Forms.WebBrowser(); this.webBrowser2.Dock = System.Windows.Forms.DockStyle.Bottom; this.webBrowser2.Location = new System.Drawing.Point(0, 34); this.webBrowser2.MinimumSize = new System.Drawing.Size(20, 20); this

Create an instance of a class from a string name in Haxe

丶灬走出姿态 提交于 2019-12-05 03:09:22
Let's say i acquire the name of a class that i made as a String . How can i Instantiate the class with the name contained in that string? I I know it will be derived from a certain parent class, but the actual class will vary. Franco Ponticelli var instance : MyClass = Type.createInstance(Type.resolveClass("path.to.MyClass"), []); Few notes: resolveClass() takes the full path (packages included) of the classe you need createInstance() takes as the second argument an array of values that are applied to the constructor. Those values must be in the exact number and must be passed even if they are

In Java what happens when an object fails to be instantiated?

二次信任 提交于 2019-12-05 02:25:35
I come from a c++ background and I find myself constantly doing this in java: SomeClass sc=new SomeClass(); if(null!=sc) { sc.doSomething(); } What I want to know is what will be in the variable sc if the constructor fails for some reason (like maybe not enough memory). I can' t find a straight answer, and I am worried that I am just wasting my time because maybe if the new operator fails would the program just crash anyway? polygenelubricants The Java Specification Language 3rd Edition covers your question thoroughly: 12.5 Creation of New Class Instances Whenever a new class instance is

Why does the compiler try to instantiate a template that I don't actually instantiate anywhere?

守給你的承諾、 提交于 2019-12-05 00:43:54
Updated below . The following is the entire code I have in my main.cpp: template<class T> struct other_traits; template<class T> struct some_traits{ typedef decltype(&T::operator()) Fty; typedef typename other_traits<Fty>::type type; }; int main(){ } But I get the following errors with Visual Studio 2010 while g++ compiles just fine : src\main.cpp(9): error C2146: syntax error : missing ';' before identifier 'type' --src\main.cpp(10) : see reference to class template instantiation ' some_traits<T> ' being compiled src\main.cpp(9): error C2868: ' some_traits<T>::type ' : illegal syntax for