Search Results

Search found 24043 results on 962 pages for 'private methods'.

Page 72/962 | < Previous Page | 68 69 70 71 72 73 74 75 76 77 78 79  | Next Page >

  • How to pass a class method as an argument for another function in C++ and openGL?

    - by tsubasa
    I know this thing works: void myDisplay() { ... } int main() { ... glutDisplayFunc(myDisplay) ... } so I tried to include myDisplay() function to a class that I made. Because I want to overload it in the future with a different class. However, the compiler complains that argument of type 'void (ClassBlah::)()' does not match 'void(*)()' . Here is the what I try to make: class ClassBlah { .... void myDisplay() .... } ...... int main() { ... ClassBlah blah glutDisplayFunc(blah.myDisplay) ... } Does anybody knows how to fix this problem? Many thanks.

    Read the article

  • Method in RootViewController not Storing Array

    - by Antonio
    I have an array initialized in my RootViewController and a method that addsObjects to an array. I created a RootViewController object in my SecondViewController. The method runs (outputs a message) but it doesn't add anything to the array, and the array seems empty. Code is below, any suggestions? RootViewController.h #import "RootViewController.h" #import "SecondViewController.h" @implementation RootViewController - (void)viewDidLoad { [super viewDidLoad]; myArray2 = [[NSMutableArray alloc] init]; NSLog(@"View was loaded"); } -(void)addToArray2{ NSLog(@"Array triggered from SecondViewController"); [myArray2 addObject:@"Test"]; [self showArray2]; } -(void)showArray2{ NSLog(@"Array Count: %d", [myArray2 count]); } -(IBAction)switchViews{ SecondViewController *screen = [[SecondViewController alloc] initWithNibName:nil bundle:nil]; screen.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [self presentModalViewController:screen animated:YES]; [screen release]; } SecondViewController.m #import "SecondViewController.h" #import "RootViewController.h" @implementation SecondViewController -(IBAction)addToArray{ RootViewController *object = [[RootViewController alloc] init]; [object addToArray2]; } -(IBAction)switchBack{ [self dismissModalViewControllerAnimated:YES]; } EDIT***** With Matt's code I got the following error: " expected specifier-qualifier-list before 'RootViewController' "

    Read the article

  • Why can't you call a non-static method from a static method?

    - by VoodooChild
    I have a static method [Method1] in my class, which calls another method [Method2] in the same class and is not a static method. But this is a no-no. I get this error: An object reference is required for the non-static field, method, or property "ClassName.MethodName()" Can someone please briefly describe why? including other things that might be related to this.

    Read the article

  • Extension method not working if I set controller property in Action, works in OnExecuting

    - by Blankman
    I have a class MyController that inherits from Controller, so all my controllers inherit from MyController. I have a property in MyController: public class MyController : Controller { public string SomeProperty {get;set;} } if I set this property in MyController's OnExecuting method, my HtmlHelper extension method works fine: public static string SomeExtension(this HtmlHelper htmlHelper) { StringBuilder sb = new StringBuilder(); string result = ""; var controller = htmlHelper.ViewContext.Controller as MyController; if (controller != null) { result = controller.SomeProperty; } return result; } it doesn't work if I set 'SomeProperty' in my controllers action method. I guess because I am doing 'as MyController' in the extension method? is there a way for it to work in both situations? I am using the value of SomeProperty to be outputted on my view pages.

    Read the article

  • Why isn't this simple test class's method inherited in Ruby?

    - by Kevin Bannister
    Consider this very simple logging class: class MockLog def self.log_stub_method(*args) args.each do |a| define_method "#{a}" do |msg| t = Time.now.strftime("%Y-%m-%d %H:%M:%S") $stderr.puts "[#{a.upcase}] \u00bb [#{t}] #{msg}" end end end log_stub_method :fatal, :error, :warn, :info, :debug end Let's add logging to all our classes: class Module def has_logging() class_eval { @log = MockLog.new def log self.class.instance_variable_get :@log end } end end Now, why doesn't this work? class Foo has_logging end Foo.new.log.nil? # => false, as expected class Bar < Foo end Bar.new.log.nil? # => true?! Why wasn't the `log` method inherited?

    Read the article

  • Calling gwt static method from parent of iframe

    - by Richard Wallis
    I'd like to know how to call a GWT static method from the parent of the iframe in which the gwt module is loaded. As a simple example suppose I have the following gwt class: public class Simple { public static void showWindow() { Window.alert("Hello from the iframe"); } } I create an html host page called "iFrameHost.html" that can run the function above. Then in an unrelated GWT module on a different page I call: Frame iFrame = new Frame("iFrameHost.html"); RootPanel.get().add(iFrame); How do I now call the showWindow() method from the parent page?

    Read the article

  • How Can open root in iphone?

    - by Fatemeh
    Hi , I want to knowing how can i open root directory ? I know Messages saved in sms.db that is in "/var/root/Library/SMS/sms.db" , but I can not see sub folder of root, I know ,the root have password and should enter it to open ,... but how can open this without Unlock or entering password?

    Read the article

  • How should I deal with floating numbers that numbers that can get so small that the become zero

    - by Tristan Havelick
    So I just fixed an interesting bug in the following code, but I'm not sure the approach I took it the best: p = 1 probabilities = [ ... ] # a (possibly) long list of numbers between 0 and 1 for wp in probabilities: if (wp > 0): p *= wp # Take the natural log, this crashes when 'probabilites' is long enough that p ends up # being zero try: result = math.log(p) Because the result doesn't need to be exact, I solved this by simply keeping the smallest non-zero value, and using that if p ever becomes 0. p = 1 probabilities = [ ... ] # a long list of numbers between 0 and 1 for wp in probabilities: if (wp > 0): old_p = p p *= wp if p == 0: # we've gotten so small, its just 0, so go back to the smallest # non-zero we had p = old_p break # Take the natural log, this crashes when 'probabilites' is long enough that p ends up # being zero try: result = math.log(p) This works, but it seems a bit kludgy to me. I don't do a ton of this kind of numerical programming, and I'm not sure if this is the kind of fix people use, or if there is something better I can go for.

    Read the article

  • How do I show and position an Image initialized in the codebehind on my page?

    - by Andreas Strandfelt
    Hello. I have created a simple method to check if an image has been approved and finally returns it as an control. But how do i call and show it on the page? I've tried something like this in the aspx-file: <% SendImage("DKBygMiniLogo.gif", "True"); %> Here is the simple method: protected Image SendImage(object Image, object Approved) { bool approved = Convert.ToBoolean(Approved); Image img = new Image(); if (approved) { img.ImageUrl = "~/images/Ads/" + Image.ToString(); img.Visible = true; } else { img.ImageUrl = "~/images/Ads/" + Image.ToString(); img.Visible = false; } return img; } How do I actually show the image?

    Read the article

  • Anonymous method as function result

    - by iamjoosy
    What I want to do is to assign an anonymous method which I get as a function result to a variable of the same type. Delphi complains about not beeing able to do the assignement. Obviously Delphi things I want to assign the "GetListener" function instead of the result of that same function. Any help with this is very much appreciated. type TPropertyChangedListener = reference to procedure (Sender: TStimulus); TMyClass = class function GetListener:TPropertyChangedListener end; .... var MyClass: TMyClass; Listener: TPropertyChangedListener; begin MyClass:= TMyClass.create; Listener:= MyClass.GetListener; // Delphi compile error: E2010 Incompatible types: TPropertyChangedListener' and 'Procedure of object' end;

    Read the article

  • Whats wrong with this method?

    - by David
    Here's the method: public static String CPUcolor () { System.out.println ("What color am I?") ; String s = getIns() ; System.out.println ("are you sure I'm "+s+"? (Y/N)") ; String a = getIns() ; while (!((a.equals ("y")) || (a.equals ("Y")) || (a.equals ("n")) || (a.equals ("N")))) { System.out.println ("try again") ; a = getIns () ; } if (a.equals ("n") || a.equals("N")) {CPUcolor() ;} System.out.println ("I am "+s) ; return s ; } here is a possible output of this method (y's and n's are user inputs): What color am I? red are you sure I'm red? (Y/N) N What color am I? blue are you sure I'm blue? (Y/N) N What color am I? Yellow are you sure I'm Yellow? (Y/N) y I am Yellow I am blue I am red Why is it that the line's "I am blue" and "I am Blue" printed? Why are they printed in reverse order with red, the first entered, printed last?

    Read the article

  • Does iPhone SDK Objective C support functions inside of functions?

    - by Moshe
    I know that javascript, for example supports functions inside of functions, like so: function doSomething(){ function doAnothingThing(){ //this function is redefined every time doSomething() is called and only exists inside doSomething() } //you can also stick it inside of conditions if(yes){ function doSomethingElse(){ //this function only exists if yes is true } } } Does objective-c support this? Theoretical example: -(void) doSomething:(id) sender{ -(void) respondToEvent: (id) sender{ //theoretically? ... please? } } BONUS: What is the proper term for a "local" function?

    Read the article

  • Javascript - cannot make static reference to non-static function ....

    - by Ankur
    I am making a reference to the Javascript function splice() on an array and I get the error: "Cannot make a static reference to the non-static function splice()" What's going on - how is this a static reference, aren't I referencing an instance of an Array class and its method - how is that static? $(document).ready( function() { var queryPreds = new Array(); var queryObjs = new Array(); function remFromQuery(predicate) { for(var i=0; i<arrayName.length;i++ ) { if(queryPreds[i]==predicate) queryPreds.splice(i,1); queryObjs.splice(i,1); } } }

    Read the article

  • File Segmentation when trying to write in a file

    - by user1286390
    I am trying in C language to use the method of bisection to find the roots of some equation, however when I try to write every step of this process in a file I get the problem "Segmentation fault". This might be an idiot fault that I did, however I have been trying to solve this for a long time. I am compiling using gcc and that is the code: #include <stdio.h> #include <stdlib.h> #include <math.h> #define R 1.0 #define h 1.0 double function(double a); void attractor(double *a1, double *a2, double *epsilon); void attractor(double *a1, double *a2, double *epsilon) { FILE* bisection; double a2_copia, a3, fa1, fa2; bisection = fopen("bisection-part1.txt", "w"); fa1 = function(*a1); fa2 = function(*a2); if(function(*a1) - function(*a2) > 0.0) *epsilon = function(*a1) - function(*a2); else *epsilon = function(*a2) - function(*a1); fprintf(bisection, "a1 a2 fa1 fa2 epsilon\n"); a2_copia = 0.0; if(function(*a1) * function(*a2) < 0.0 && *epsilon >= 0.00001) { a3 = *a2 - (*a2 - *a1); a2_copia = *a2; *a2 = a3; if(function(*a1) - function(*a2) > 0.0) *epsilon = function(*a1) - function(*a2); else *epsilon = function(*a2) - function(*a1); if(function(*a1) * function(*a2) < 0.0 && *epsilon >= 0.00001) { fprintf(bisection, "%.4f %.4f %.4f %.4f %.4f\n", *a1, *a2, function(*a1), function(*a1), *epsilon); attractor(a1, a2, epsilon); } else { *a2 = a2_copia; *a1 = a3; if(function(*a1) - function(*a2) > 0) *epsilon = function(*a1) - function(*a2); else *epsilon = function(*a2) - function(*a1); if(function(*a1) * function(*a2) < 0.0 && *epsilon >= 0.00001) { fprintf(bisection, "%.4f %.4f %.4f %.4f %.4f\n", *a1, *a2, function(*a1), function(*a1), *epsilon); attractor(a1, a2, epsilon); } } } fa1 = function(*a1); fa2 = function(*a2); if(function(*a1) - function(*a2) > 0.0) *epsilon = function(*a1) - function(*a2); else *epsilon = function(*a2) - function(*a1); fprintf(bisection, "%.4f %.4f %.4f %.4f %.4f\n", a1, a2, fa1, fa2, epsilon); } double function(double a) { double fa; fa = (a * cosh(h / (2 * a))) - R; return fa; } int main() { double a1, a2, fa1, fa2, epsilon; a1 = 0.1; a2 = 0.5; fa1 = function(a1); fa2 = function(a2); if(fa1 - fa2 > 0.0) epsilon = fa1 - fa2; else epsilon = fa2 - fa1; if(epsilon >= 0.00001) { fa1 = function(a1); fa2 = function(a2); attractor(&a1, &a2, &epsilon); fa1 = function(a1); fa2 = function(a2); if(fa1 - fa2 > 0.0) epsilon = fa1 - fa2; else epsilon = fa2 - fa1; } if(epsilon < 0.0001) printf("Vanish at %f", a2); else printf("ERROR"); return 0; } Thanks anyway and sorry if this question is not suitable.

    Read the article

  • Design and Implementation with Prototyping Methodology

    - by Shahin
    I'm developing a game for my dissertation, and I'm using the spiral method approach. I'm having a bit of difficulty structuring my dissertation, specifically the design and implementation section. My solution was designed as much as possible initially, and then after each prototype implementation, the design was refined and extended and prototyped again (this was repeated a few times). My problem is how to structure this in my dissertation, my current idea is: Design Chapter Prototype 1 (Initial) Design Prototype 2 Design Prototype 3 Design Implementation Chapter Prototype 1 (Initial) Implementation Prototype 2 Implementation Prototype 3 Implementation Any suggestions?

    Read the article

  • can't access to an extension method with UrlHelper parameter in controller! Vice versa in view have

    - by Sadegh
    why defined extension method with UrlHelper don't added in Url.EXTENSIONMETHOD when i want to use it in controller! but i have access to it in view? public static string Home(this UrlHelper helper) { return helper.RouteUrl("ABC", new { controller = "ABC", Action = "Default" }); } i haven't access: public ActionResult Default() { return Redirect(Url.Home()); } i have access in view: <a href="<%=Url.Home() %>" title="Hello">Hello</a>

    Read the article

  • Memory management in iOS

    - by angrest
    Looks like I did not understand memory management in Objective C... sigh. I have the following code (note that in my case, placemark.thoroughfare and placemark.subThoroughfare are both filled with valid data, thus both if-conditions will be TRUE if (placemark.thoroughfare) { [item.place release]; item.place = [NSString stringWithFormat:@"%@ ", placemark.thoroughfare]; } else { [item.place release]; item.place = @"Unknown Place"; } if (placemark.thoroughfare && placemark.subThoroughfare) { // *** problem is here *** [item.place release]; item.place = [NSString stringWithFormat:@"%@ %@", placemark.thoroughfare , placemark.subThoroughfare]; } If I do not release item.place at the marked location in the code, Instruments finds a memory leak there. If I do, the program crashes as soon as I try to access item.place outside the offending method. Any ideas?

    Read the article

  • Error message in XSLT with C# extension function

    - by iHeartGreek
    Hi! I am received the following error while trying to implement a C# extension function in XSLT. Extension function parameters or return values which have CLR type 'Char[]' are not supported.** code: <xsl:variable name="stringList"> <xsl:value-of select="extension:GetList('AAA BBB CCC', ' ')"/> </xsl:variable> <msxsl:script language="C#" implements-prefix="extension"> <![CDATA[ public string[] GetList(string str, char[] delimiter) { ... ... return str.Split(delimiter, StringSplitOptions.None); } ]]> </msxsl:script> Can someone explain this error message and how to get past it? Thanks!

    Read the article

  • Ruby: Alter class static method in a code block

    - by Phuong Nguy?n
    Given the Thread class with it current method. Now inside a test, I want to do this: def test_alter_current_thread Thread.current = a_stubbed_method # do something that involve the work of Thread.current Thread.current = default_thread_current end Basically, I want to alter the method of a class inside a test method and recover it after that. I know it sound complex for another language, like Java & C# (in Java, only powerful mock framework can do it). But it's ruby and I hope such nasty stuff would be available

    Read the article

< Previous Page | 68 69 70 71 72 73 74 75 76 77 78 79  | Next Page >