Search Results

Search found 37528 results on 1502 pages for 'function'.

Page 9/1502 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Question about member function pointers in a heirarchy

    - by Jesse Beder
    I'm using a library that defines an interface: template<class desttype> void connect(desttype* pclass, void (desttype::*pmemfun)()); and I have a small heirarchy class base { void foo(); }; class derived: public base { ... }; In a member function of derived, I want to call connect(this, &derived::foo); but it seems that &derived::foo is actually a member function pointer of base; gcc spits out error: no matching function for call to ‘connect(derived* const&, void (base::* const&)())’ I can get around this by explicitly casting this to base *; but why can't the compiler match the call with desttype = base (since derived * can be implicitly cast to base *)? Also, why is &derived::foo not a member function pointer of derived?

    Read the article

  • How to fix MySQL CREATE FUNCTION query?

    - by Liutas
    I want to add mysql function: CREATE FUNCTION `chf_get_translation`(translation_id INT, site_lang INT) RETURNS text CHARSET utf8 BEGIN DECLARE translation TEXT; SELECT title INTO translation FROM chf_translations WHERE key_id = translation_id AND lang_id = site_lang; RETURN translation; END But get error: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3 What can be wrong with this function?

    Read the article

  • Understanding an interesting array update/replace function

    - by dave
    I'm a PHP amateur. This array function is an adaption of a function I noticed while reading this article. I thought this was an interesting type of array function, but I have a question about the way it works. my_func( array( 'sky' => 'blue' ) ); function my_func( array $settings = array() ) { $settings = $settings + array( 'grass'=>'green','sky'=>'dark' ); print_r( $settings ) ; // outputs: Array ( [sky] => blue [grass] => green ) } but..................... my_func( array( 'sky' => 'blue' ) ); function my_func( array $settings = array() ) { $settings = array( 'clock'=>'time' ) ; $settings = $settings + array( 'grass'=>'green','sky'=>'dark' ); print_r( $settings ) ; // outputs: Array ( [clock] => time [grass] => green [sky] => dark ) } Why does [sky] not equal 'blue' in the second instance? Thanks.

    Read the article

  • variable names in function definition, call and declaration

    - by yCalleecharan
    Hi, I see C books that use the same variable names in the function definition, calling function and declaration. Others use the same variable names in the calling function and in the declaration/prototype but a different one in the definition as in: void blabla(int something); //prototype blabla(something) // calling function inside main after something has been initialized to int void blabla(int something_else) //definition I have two questions: What convention is best to use in C?; Does the convention apply regardless whether a value is being passed "by-value" or if it's being passed by a pointer? Thanks a lot...

    Read the article

  • Attach fancybox/lightbox/idontknowbox function on an element

    - by tanathos
    I'm developing a jquery gallery, and I want to parametrize the highlighter function to support any kind of lightboxes (fancybox for example). In my defaults I did something like: $.fn.mygallery.defaults = { functionHighlighter: null } so in the code, creating the item, I'll check this property, and if it's setted to a function, I want to call it on the element: if ((typeof opt.functionHighlighter) === "function") { opt.functionHighlighter.call(link); } where link is the anchor element containing the miniature image, with href setted to the original image. In my idea, when the plugin is called, I set the function with: $("#gallery").mygallery({ functionHighlighter: $.fancybox }); but the "call" on the functionHighlighter executes directly the fancybox, that returns an empty area. What I want to emulate is the execution of link.fancybox(); that correctly builds the plugin on link. Any ideas?

    Read the article

  • Interface function C#

    - by user181421
    Hello, I have a function which implement an interface. something like this: string IMyInterface.MyFunction() { do something; } This function is available outside of my class. All working perfect. Now I also need to call this function from another LOCAL non public function. like this: void Func2() { string s; s = MyFunction(); } The problem is I get this error: "the name MyFunction does not exist in the current context local" Any help will be appreciated. TY.

    Read the article

  • Pass function as parameter in PHP

    - by Casidiablo
    Hello everybody! I've been wondering whether is possible or not to pass a function as parameter in PHP; I want something like when you're programming in JS: object.exampleMethod(function(){ // some stuff to execute }); What I want is to execute that function somewhere in exampleMethod. Is that possible in PHP? Thank you so much.

    Read the article

  • Returning char* in function

    - by Devel
    I have function: char *zap(char *ar) { char pie[100] = "INSERT INTO test (nazwa, liczba) VALUES ('nowy wpis', '"; char dru[] = "' )"; strcat(pie, ar); strcat(pie, dru); return pie; } and in main there is: printf("%s", zap( argv[1] ) ); When compiling I get the warning: test.c: In function ‘zap’: test.c:17: warning: function returns address of local variable How should I return char* propertly?

    Read the article

  • function prototype declarations

    - by sandy101
    I am practice the function in c and come across to the program .... #include<stdio.h> int main() { float a=15.5; char ch ='C'; printit(a,ch); return 0; } printit(a,ch) { printf("%f\n%c",a,ch); } I want to know that why the above program compile and not give the error as i understood so for is ... The function in c must be declared with the specific prototype (but this program does not contain the prototype) why the program give the output 'x'for the char variable ? can the function in c are capable of accepting the value without being declared about type in parameters like what has done in the function declaration ?

    Read the article

  • function with array variable

    - by mtokoly
    How do I pass an array through a function, for example: $data = array( 'color' => 'red', 'height' => 'tall' ); something($data); function something($data) { if ($data['color'] == 'red') { // do something } } how can I get the function to recognize $data[color] and $data[height]?

    Read the article

  • how to load a page and then run a jquery function

    - by Khawar
    on master page i put this code to load page in same master page and then run jqeury function i m trying this $(document).ready(function() { $("#mainContactLink").click(function() { $(body).open("about-us.aspx", self); $(" #abtContacts").fadeIn(1000).siblings("div").fadeOut(100); $(" #abtContacts").siblings(); }); }); its not working.. any idea ?

    Read the article

  • calling a function from another function in python

    - by user1040503
    I have written this function that takes to strings in order to see if they are anagrams: def anagram_check(str_x, str_y): x = string1.replace(" ","") y = string2.replace(" ","") lower1 = x.lower() lower2 = y.lower() sorted1 = sorted(lower1) sorted2 = sorted(lower2) if sorted1 == sorted2: return True else: return False this function works fine, the problem is that now I need to use this function in another function in order to find anagrams in a text file. I want to print a list of tuples with all the anagrams in it. this is what i have done so far def anagrams_finder(words_num): anagrams = [] f = open("words.txt") a = list(f) list1 = ([s.replace('\n', '') for s in a]) list2 = ([i.lower() for i in list1]) list3 = list2[0:words_num] #number of words from text that need to be checked. for i in list3: .... I tried using for loops, while loops, appand.... but nothing seems to work. how can I use the first function in order to help me with the second? Please help...

    Read the article

  • Python function correctly/incorrectly?

    - by Anthony Kernan
    I'm just starting too use python, learning experience. I know the basics logic of programming. I have a function in python that is running everytime, even when it's not supposed to. I use an if statement in the beginning of the function. I don't know why this if statement is not working, confused. I have another function that is similar and works correctly. Am I missing something simple? Here's the function that is not working... def check_artist_art(): if os.path.exists("/tmp/artistinfo") and open("/tmp/artistinfo").read() != title: #if artist == "": if os.path.exists(home + "/.artist"): os.remove(home + "/.artist") if os.path.exists("/tmp/artistinfo"): os.remove("/tmp/artistinfo") print artist return False else: os.path.exists("/tmp/artistinfo") and open("/tmp/artistinfo").read() == artist return False return True And this is the similar function that is working correctly.. def check_album(): if os.path.exists("/tmp/albuminfo") and open("/tmp/albuminfo").read() != album: if os.path.exists(home + "/.album"): os.remove(home + "/.album") if os.path.exists("/tmp/albuminfo"): os.remove("/tmp/albuminfo") return False elif os.path.exists("/tmp/trackinfo") and open("/tmp/trackinfo").read() == artist + album: return False return True Any help is greatly appreciated.

    Read the article

  • PHP getimagesize is not working when is called from a function in function.php (Wordpress)?

    - by janoChen
    PHP getimagesize is not working when is called from a function in function.php. function.php: add_action('wp_head', 'get_image_size'); function get_image_size() { global $width; // I thought this would solve the problem but it didn't global $height; // I thought this would solve the problem but it didn't list($width, $height, $type, $attr) = getimagesize($options['logo']); echo "Image width " .$width; echo "<BR>"; echo "Image height " .$height; echo "<BR>"; } $options['logo'] is returning http://localhost/wordpress/wp-content/uploads/2010/12/logo4.png so the image is being displayed. I also did var_dump to $width and $height but they didn't show up. Any suggestions?

    Read the article

  • how to callback a lua function from a c function

    - by pierr
    Hi, I have a c function test_callback accepting a point to a function as the parameter and It will "callback" that function. //typedef int(*data_callback_t)(int i); int test_callback(data_callback_t f) { f(3); } int datacallback(int a ) { printf("called back %d\n",a); return 0; } //example test_callback(datacallback); // print : called back 3 Now, I want to wrap test_callback so that they can be called from lua, suppose the name is lua_test_callback ;and also the input parameter to it would be a lua function. How should I achieve this goal? function lua_datacallback (a ) print "hey , this is callback in lua" ..a end lua_test_callback(lua_datacallback) //expect to get "hey this is callback in lua 3 "

    Read the article

  • What are function pointers good for ?

    - by gramm
    Hi, I have trouble seing the utility of the function pointers. I guess it may be useful in some case (it exists, after all), but I can't think of a case where it's better or unavoidable to use a function pointer. Could you give some example of good use of function pointers (in C or C++)? Many thanks :)

    Read the article

  • C++ inheritance and member function pointers

    - by smh
    In C++, can member function pointers be used to point to derived (or even base) class members? EDIT: Perhaps an example will help. Suppose we have a hierarchy of three classes X, Y, Z in order of inheritance. Y therefore has a base class X and a derived class Z. Now we can define a member function pointer p for class Y. This is written as: void (Y::*p)(); (For simplicity, I'll assume we're only interested in functions with the signature void f() ) This pointer p can now be used to point to member functions of class Y. This question (two questions, really) is then: Can p be used to point to a function in the derived class Z? Can p be used to point to a function in the base class X?

    Read the article

  • I need help understanding how this jQuery filter function works, line-by-line, if possible

    - by user717236
    Here is the HTML: <div> <h3>text</h3> </div> <div> <h3>moretext</h3> </div> <div> <h3>123</h3> </div>?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? Here is the JS: var rv1_wlength = $("div").filter(function() { return $(this).find("h3").filter(function () { return $(this).text() != "123"; }).length; }); var rv1_wolength = $("div").filter(function() { return $(this).find("h3").filter(function () { return $(this).text() != "123"; }); }); var rv2 = $("div").find("h3").filter(function() { return $(this).text() != "123"; }); alert(rv1_wlength.text()); // text // moretext alert(rv1_wolength.text()); // text // moretext // 123 alert(rv2.text());? // textmoretext I don't understand why the first two methods print the elements on each line, whereas the second method concatenates them. "rv2" is a jQuery object. Then, what are the first two (rv1_wlength and rv1_wolength)? Furthermore, I don't understand why the inclusion of the length property makes all the difference in filtering the elements. The second method does nothing, since it returns all the elements. The first method, with the only change being the addition of the length property, correctly filters the elements. I would very much like a line-by-line explanation. I would sincerely appreciate any feedback. Thank you.

    Read the article

  • pointer to const member function typedef

    - by oldcig
    I know it's possible to separate to create a pointer to member function like this struct K { void func() {} }; typedef void FuncType(); typedef FuncType K::* MemFuncType; MemFuncType pF = &K::func; Is there similar way to construct a pointer to a const function? I've tried adding const in various places with no success. I've played around with gcc some and if you do template deduction on something like template <typename Sig, typename Klass> void deduce(Sig Klass::*); It will show Sig with as a function signature with const just tacked on the end. If to do this in code it will complain that you can't have qualifiers on a function type. Seems like it should be possible somehow because the deduction works.

    Read the article

  • calling function in radiobutton group

    - by vijisai
    thank you very much. with your help, i am now able to call the function for each radio button. however, i get a error message Reference to non-existent field 'ics_si' ics_si is my function, which has the following code, i do not know where i am making a mistake i have created the edit box for user to input the values for bore and stroke. and vdisp is calculated and the result is displayed in the third edit box. function ics_si_Callback(hObject, eventdata, handles) b = str2double(get(handles.bore,'String')); s = str2double(get(handles.stroke,'String')); vdisp = (pi * b * b * s*10^(-3))/4; set(handles.vdisp,'String',vdisp); this code must be called when i press the first or second radio button. i.e. when the radio button is pressed, it should call the function ics_si, calculate it and display the result. how to get this.

    Read the article

  • Giving my function access to outside variable

    - by brett
    I have an array outside: $myArr = array(); I would like to give my function access to the array outside it so it can add values to it function someFuntion(){ $myVal = //some processing here to determine value of $myVal $myArr[] = $myVal; } How do I give the function the right scoping to the variable?

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >