Search Results

Search found 40165 results on 1607 pages for 'function pointers'.

Page 26/1607 | < Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >

  • how to Clean up(destructor) a dynamic Array of pointers??

    - by Ahmed Sharara
    Is that Destructor is enough or do I have to iterate to delete the new nodes?? #include "stdafx.h" #include<iostream> using namespace std; struct node{ int row; int col; int value; node* next_in_row; node* next_in_col; }; class MultiLinkedListSparseArray { private: char *logfile; node** rowPtr; node** colPtr; // used in constructor node* find_node(node* out); node* ins_node(node* ins,int col); node* in_node(node* ins,node* z); node* get(node* in,int row,int col); bool exist(node* so,int row,int col); //add anything you need public: MultiLinkedListSparseArray(int rows, int cols); ~MultiLinkedListSparseArray(); void setCell(int row, int col, int value); int getCell(int row, int col); void display(); void log(char *s); void dump(); }; MultiLinkedListSparseArray::MultiLinkedListSparseArray(int rows,int cols){ rowPtr=new node* [rows+1]; colPtr=new node* [cols+1]; for(int n=0;n<=rows;n++) rowPtr[n]=NULL; for(int i=0;i<=cols;i++) colPtr[i]=NULL; } MultiLinkedListSparseArray::~MultiLinkedListSparseArray(){ // is that destructor enough?? cout<<"array is deleted"<<endl; delete [] rowPtr; delete [] colPtr; }

    Read the article

  • Dereferencing deleted pointers always result in an Access Violation ??

    - by m3rLinEz
    I have a very simple C++ code here: char *s = new char[100]; strcpy(s, "HELLO"); delete [] s; int n = strlen(s); If I run this code from Visual C++ 2008 by pressing F5 (Start Debugging,) this always result in crash (Access Violation.) However, starting this executable outside the IDE, or using the IDE's Ctrl+F5 (Start without Debugging) doesn't result in any crash. What could be the difference? I also want to know if it's possible to stably reproduce the Access Violation crash caused from accessing deleted area? Is this kind of crash rare in real-life?

    Read the article

  • Pointers to a typed variable in C#: Interfase, Generic, object or Class? (Boxing/Unboxing)

    - by PaulG
    First of all, I apologize if this has been asked a thousand times. I read my C# book, I googled it, but I can't seem to find the answer I am looking for, or I am missing the point big time. I am very confused with the whole boxing/unboxing issue. Say I have fields of different classes, all returning typed variables (e.g. 'double') and I would like to have a variable point to any of these fields. In plain old C I would do something like: double * newVar; newVar = &oldVar; newVar = &anotherVar; ... In C#, it seems I could do an interfase, but would require that all fields be properties and named the same. Breaks apart when one of the properties doesn't have the same name or is not a property. I could also create a generic class returning double, but seems a bit absurd to create a class to represent a 'double', when a 'double' class already exists. If I am not mistaken, it doesn't even need to be generic, could be a simple class returning double. I could create an object and box the typed variable to the newly created object, but then I would have to cast every time I use it. Of course, I always have the unsafe option... but afraid of getting to unknown memory space, divide by zero and bring an end to this world. None of these seem to be the same as the old simple 'double * variable'. Am I missing something here?

    Read the article

  • Why friend function is preferred to member function for operator<<

    - by skydoor
    When you are going to print an object, a friend operator<< is used. Can we use member function for operator<< ? class A { public: void operator<<(ostream& i) { i<<"Member function";} friend ostream& operator<<(ostream& i, A& a) { i<<"operator<<"; return i;} }; int main () { A a; A b; A c; cout<<a<<b<<c<<endl; a<<cout; return 0; } One point is that friend function enable us to use it like this cout<<a<<b<<c What other reasons?

    Read the article

  • Static member function pointer to hold non static member function

    - by user1425406
    This has defeated me. I want to have a static class variable which is a pointer to a (non-static) member function. I've tried all sorts of ways, but with no luck (including using typedefs, which just seemed to give me a different set of errors). In the code below I have the static class function pointer funcptr, and I can call it successfully from outside the class, but not from within the member function CallFuncptr - which is what I want to do. Any suggestions? #include <stdio.h> class A { public: static int (A::*funcptr)(); int Four() { return 4;}; int CallFuncptr() { return (this->*funcptr)(); } // doesn't link - undefined reference to `A::funcptr' }; int (A::*funcptr)() = &A::Four; int main() { A fred; printf("four? %d\n", (fred.*funcptr)()); // This works printf("four? %d\n", fred.CallFuncptr()); // But this is the way I want to call it }

    Read the article

  • How To Pass Class As Params to Function

    - by Asim Sajjad
    How can I pass the Parameter to a function. for example public void GridViewColumns(params ClassName[] pinputparamter) { } and Class is as given below public Class ClassName { public string Name{get;set;} public int RecordID{get;set;} } can anyone has idea?

    Read the article

  • jquery callback function

    - by kusanagi
    i use recaptcha Recaptcha.create("xxx", "recaptcha", { theme: 'clean', tabindex: 0, callback: $("#id").focus }); i want to use callback to focus some field, but it doesn't work, only callback: f works function f() { $("#FIO").focus(); } what is the problem?

    Read the article

  • Calling matlab callback/function handle from Java

    - by jakob
    How do I pass a matlab function handle to a Java object and invoke it from within Java (that is, I want Java to tell matlab when it is ready with a calculation). I am trying to use the com.mathworks.jmi.Matlab class for evaluating Matlab expressions in the Java object, but I can't see how to 1) transfer the callback funcktion handle to Java, and 2) invoke it from Java possibly using the com.mathworks.jmi.Matlab class. Thanks, jakob

    Read the article

  • PHP analog of mysql like function

    - by DCrystal
    Suppose it's a nub question, but is there an analog of mysql's LIKE function in php? So, e.g. : like('goo*','google.com');//is true like('*gl*','google.com');//true like('google.com','google.com')//also true I know regex rullez, but don't know any solution to reach this

    Read the article

  • function overloading in C

    - by FL4SOF
    Is there any way to achieve function overloading in C? I am looking at simple functions to be overloaded like foo (int a) foo (char b) foo (float c , int d) I think there is no straight forward way, looking for workarounds if any?

    Read the article

  • Get Date Strings for draw_calendar() Function

    - by Brandon
    I'm using the David Walsh PHP calendar script and need to format my date arguments like this: draw_calendar(7,2009); I want to get today's Month and Year as well as the next month and the month after that (so current month, plus one, plus one). How can I call the function three times in succession to generate these three calendars only knowing today's Month and Year? -Brandon

    Read the article

  • MATLAB feature function

    - by yuk
    I'm curious where to find a complete description of FEATURE function? Which arguments it accepts? No documentation was found. I heard only about memstats and getpid. Anything else? >> which feature built-in (undocumented)

    Read the article

  • Registering a Named Function as a Listener with Jquery

    - by Marcus
    I'm new to javascript/jquery and I've done some poking around the web, but I can't figure out why the following is invalid: var toggleSection = function(sectionName) { // Do some Jquery work to toggle stuff based on sectionName string // (concatenate sectionName with other text to form selectors) }; $('#togglecont1').click(toggleSection("container1")); Is there something obvious I'm missing? Thanks in advance.

    Read the article

  • Function overloading by return type?

    - by dsimcha
    Why don't more mainstream statically typed languages support function/method overloading by return type? I can't think of any that do. It seems no less useful or reasonable than supporting overload by parameter type. How come it's so much less popular?

    Read the article

  • How to properly use the .animate() function -- top

    - by sadmicrowave
    Is this the proper way to use the .animate(top) function? Positive number (animate down)-- $("div#container div#history-menu").animate({top:'180px'}, 600); Negative number (animate up)-- $("div#container div#history-menu").animate({top:'-180px'}, 600); Because I'm getting a java error in my error console that says: "error in parsing value for property 'top'. Declaration Dropped."

    Read the article

  • adding other parameter to function

    - by Ronnie Chester Lynwood
    hello. i got a function that listing downloads in a table with foreach. it's also lists searched term, search type. public function fetchDownloads($displaySite=true) { $downloads = array(); $sqlWhere = ""; if(isset($this->q)) { if(strlen($this->q) <= $this->recents_length && !empty($this->q)) { $insertRecent = $this->processDataHook("insertRecent",$this->q); if($insertRecent) { if(!@mysql_query("INSERT INTO wcddl_recents (query) VALUES ('".$this->qSQL."')")) { @mysql_query("UPDATE wcddl_recents SET searches = searches+1 WHERE query = '".$this->qSQL."'"); } } } if($this->search_type == "narrow") { $sqlWhere = " WHERE title LIKE '%".mysql_real_escape_string(str_replace(" ","%",$this->q))."%'"; } elseif($this->search_type == "wide") { $qExp = explode(" ",$this->q); $sqlWhere = array(); foreach($qExp as $fq) $sqlWhere[] = "title LIKE '%".mysql_real_escape_string($fq)."%'"; $sqlWhere = implode(" OR ",$sqlWhere); $sqlWhere = " WHERE (".$sqlWhere.")"; } } if(isset($this->type)) { if(!empty($sqlWhere)) { $sqlWhere .= " AND type = '".$this->typeSQL."'"; } else { $sqlWhere = " WHERE type = '".$this->typeSQL."'"; } } $sqlWhere = $this->processDataHook("fetchDownloadsSQLWhere",$sqlWhere); $this->maxPages = mysql_query("SELECT COUNT(*) FROM wcddl_downloads".$sqlWhere.""); $this->maxPages = mysql_result($this->maxPages,0); $this->numRows = $this->maxPages; $this->maxPages = ceil($this->maxPages/$this->limit); $sqlMain = "SELECT id,sid,title,type,url,dat,views,rating FROM wcddl_downloads".$sqlWhere." ORDER BY ".(isset($this->sqlOrder) ? mysql_real_escape_string($this->sqlOrder) : "id DESC")." LIMIT ".$this->pg.",".$this->limit.""; $sqlMain = $this->processDataHook("whileFetchDownloadsSQL",$sqlMain); $sqlMain = mysql_query($sqlMain); $this->processHook("whileFetchDownloads"); while($row = mysql_fetch_assoc($sqlMain)) { if($displaySite) { $downloadSite = mysql_query("SELECT name as sname, url as surl, rating as srating FROM wcddl_sites WHERE id = '".$row['sid']."'"); $downloadSite = mysql_fetch_assoc($downloadSite); $row = array_merge($row,$downloadSite); } $downloads_current = $this->mapit($row,array("stripslashes","strip_tags")); $downloads_current = $this->processDataHook("fetchDownloadsRow",$downloads_current); $downloads[] = $downloads_current; } $this->pageList = $this->getPages($this->page,$this->maxPages); $this->processHook("endFetchDownloads"); return $downloads; } I want to add if $_REQUEST['site'] is set, order downloads by sname that catching from wcddl_sites.

    Read the article

  • string function workout in php

    - by Karthik
    I have the string like this, $inp1 = "3 doses at 0[0,0], 1-2 and 6 Month[6,1] [3,2])"; in this internally, going to take the values of square bracket. How can i take this values in the square bracket? any function is there to return the string like this [0,0] [6,1] [3,2] Thanks in advance for help.

    Read the article

  • calling a stored postgres function from php

    - by KittyYoung
    Just a little confused here... I have a function in postgres, and when I'm at the pg prompt, I just do: SELECT zp('zc',10,20,90); FETCH ALL FROM zc; I'm wondering how to do this from php? I thought I could just do: $q = pg_query("SELECT zp('zc',10,20,90)"); But, how do I "fetch" from that query?

    Read the article

  • Template function in C# - Return Type?

    - by LifeH2O
    It seems that c# does not support c++ like templates. template <class myType> myType GetMax (myType a, myType b) { return (a>b?a:b); } I want my function to have return type based on its parameters, how can i achieve this in c#? How to use templates in C#

    Read the article

  • stored values within a custom function

    - by romunov
    My program takes a data.frame and crunches the numbers. At one point, values from j-th column are multiplied by a predefined values that depends on the column name (species name, actually - it's en ecological index). So far, I've been providing these values via a second data.frame by matching column names. What would be an efficient way of integrating fixed variable values within a function? I would like my program to be as portable as possible, without the need for a second data.frame file.

    Read the article

  • php eval function in iframe

    - by stefan
    i got an iframe in an echo: <iframe width='100%' height='100'>$content</iframe> $content = eval ( "\$bugs = \"" . gettemplate ('bugs') . "\";" ); but it doesnt work. how can i use the eval function from php to show the page in an iframe? thnx!

    Read the article

< Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >