Search Results

Search found 21111 results on 845 pages for 'null pointer'.

Page 6/845 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Pointer to struct, containing pointer to an object, for which I want to call a function

    - by user1795609
    So I've created an ADT which is a singly linked list made up of nodes. These Nodes each have a pointer to an object in them called data. Class Structure { struct Node { Object *data; Node *next; }; }; Node *head; I am trying to call a function in the object, like this: head = new Node; head -> data = new Object(); head -> next = NULL; cout << head -> data.print(); I keep getting the following error at compile. error: request for member 'print' in 'head-Structure::Node::data', which is of non-class type 'Object'*

    Read the article

  • Call a void* as a function without declaring a function pointer

    - by ToxIk
    I've searched but couldn't find any results (my terminology may be off) so forgive me if this has been asked before. I was wondering if there is an easy way to call a void* as a function in C without first declaring a function pointer and then assigning the function pointer the address; ie. assuming the function to be called is type void(void) void *ptr; ptr = <some address>; ((void*())ptr)(); /* call ptr as function here */ with the above code, I get error C2066: cast to function type is illegal in VC2008 If this is possible, how would the syntax differ for functions with return types and multiple parameters?

    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

  • Accessing subclass members from a superclass pointer C++

    - by Dr. Monkey
    I have an array of custom class Student objects. CourseStudent and ResearchStudent both inherit from Student, and all the instances of Student are one or the other of these. I have a function to go through the array, determine the subtype of each Student, then call subtype-specific member functions on them. The problem is, because these functions are not overloaded, they are not found in Student, so the compiler kicks up a fuss. If I have a pointer to Student, is there a way to get a pointer to the subtype of that Student? Would I need to make some sort of fake cast here to get around the compile-time error?

    Read the article

  • Member Function Pointer not quite right

    - by BlackDuck
    I have a SpecialisedRedBlackTree class that is templated. My Month class is not. In my Month class I have a private member which is an instance of SpecialisedRedBlackTree: SpecialisedRedBlackTree<Day> m_windSpeedTree; As you can see it will take the Day class/object (please correct me on any terms I get wrong). In my Month class, I have a method passing a method function pointer to this method: bool Month::CompareWindSpeed(Day a, Day b) { return ( a.GetData(WIND_SPEED_CODE) < b.GetData(WIND_SPEED_CODE)? true : false); } bool (Month::*myFuncPtr)(Day, Day); myFuncPtr = &Month::CompareWindSpeed; m_windSpeedTree.Insert(dayReading, myFuncPtr); But because I am passing a bool (Day, Day) pointer to a templated class expecting bool (T, T) T being part of this .... template Error 1 error C2664: 'SpecialisedRedBlackTree<T>::Insert' : cannot convert parameter 2 from 'bool (__thiscall Month::* )(Day,Day)' to 'bool (__cdecl *)(T,T)' Any advice?

    Read the article

  • Can I catch bad pointer errors in C++?

    - by Simon
    Hi there, I was wondering if there is a possibility to catch errors like this in C++: object* p = new object; delete p; delete p; //this would cause an error, can I catch this? Can I check if the pointer is valid? Can I catch some exception? I know I could set the pointer p to NULL after the first object deletion. But just imagine you wouldn't do that. I am using VC++ with Visual Studio 2008/2010. Thank you

    Read the article

  • How can I optimize this subqueried and Joined MySQL Query?

    - by kevzettler
    I'm pretty green on mysql and I need some tips on cleaning up a query. It is used in several variations through out a site. Its got some subquerys derived tables and fun going on. Heres the query: # Query_time: 2 Lock_time: 0 Rows_sent: 0 Rows_examined: 0 SELECT * FROM ( SELECT products . *, categories.category_name AS category, ( SELECT COUNT( * ) FROM distros WHERE distros.product_id = products.product_id) AS distro_count, (SELECT COUNT(*) FROM downloads WHERE downloads.product_id = products.product_id AND WEEK(downloads.date) = WEEK(curdate())) AS true_downloads, (SELECT COUNT(*) FROM views WHERE views.product_id = products.product_id AND WEEK(views.date) = WEEK(curdate())) AS true_views FROM products INNER JOIN categories ON products.category_id = categories.category_id ORDER BY created_date DESC, true_views DESC ) AS count_table WHERE count_table.distro_count > 0 AND count_table.status = 'published' AND count_table.active = 1 LIMIT 0, 8 Heres the explain: +----+--------------------+------------+-------+---------------+-------------+---------+------------------------------------+------+----------------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+--------------------+------------+-------+---------------+-------------+---------+------------------------------------+------+----------------------------------------------+ | 1 | PRIMARY | <derived2> | ALL | NULL | NULL | NULL | NULL | 232 | Using where | | 2 | DERIVED | categories | index | PRIMARY | idx_name | 47 | NULL | 13 | Using index; Using temporary; Using filesort | | 2 | DERIVED | products | ref | category_id | category_id | 4 | digizald_db.categories.category_id | 9 | | | 5 | DEPENDENT SUBQUERY | views | ref | product_id | product_id | 4 | digizald_db.products.product_id | 46 | Using where | | 4 | DEPENDENT SUBQUERY | downloads | ref | product_id | product_id | 4 | digizald_db.products.product_id | 14 | Using where | | 3 | DEPENDENT SUBQUERY | distros | ref | product_id | product_id | 4 | digizald_db.products.product_id | 1 | Using index | +----+--------------------+------------+-------+---------------+-------------+---------+------------------------------------+------+----------------------------------------------+ 6 rows in set (0.04 sec) And the Tables: mysql> describe products; +---------------+--------------------------------------------------+------+-----+-------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+--------------------------------------------------+------+-----+-------------------+----------------+ | product_id | int(10) unsigned | NO | PRI | NULL | auto_increment | | product_key | char(32) | NO | | NULL | | | title | varchar(150) | NO | | NULL | | | company | varchar(150) | NO | | NULL | | | user_id | int(10) unsigned | NO | MUL | NULL | | | description | text | NO | | NULL | | | video_code | text | NO | | NULL | | | category_id | int(10) unsigned | NO | MUL | NULL | | | price | decimal(10,2) | NO | | NULL | | | quantity | int(10) unsigned | NO | | NULL | | | downloads | int(10) unsigned | NO | | NULL | | | views | int(10) unsigned | NO | | NULL | | | status | enum('pending','published','rejected','removed') | NO | | NULL | | | active | tinyint(1) | NO | | NULL | | | deleted | tinyint(1) | NO | | NULL | | | created_date | datetime | NO | | NULL | | | modified_date | timestamp | NO | | CURRENT_TIMESTAMP | | | scrape_source | varchar(215) | YES | | NULL | | +---------------+--------------------------------------------------+------+-----+-------------------+----------------+ 18 rows in set (0.00 sec) mysql> describe categories -> ; +------------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------+------------------+------+-----+---------+----------------+ | category_id | int(10) unsigned | NO | PRI | NULL | auto_increment | | category_name | varchar(45) | NO | MUL | NULL | | | parent_id | int(10) unsigned | YES | MUL | NULL | | | category_type_id | int(10) unsigned | NO | | NULL | | +------------------+------------------+------+-----+---------+----------------+ 4 rows in set (0.00 sec) mysql> describe compatibilities -> ; +------------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------+------------------+------+-----+---------+----------------+ | compatibility_id | int(10) unsigned | NO | PRI | NULL | auto_increment | | name | varchar(45) | NO | | NULL | | | code_name | varchar(45) | NO | | NULL | | | description | varchar(128) | NO | | NULL | | | position | int(10) unsigned | NO | | NULL | | +------------------+------------------+------+-----+---------+----------------+ 5 rows in set (0.01 sec) mysql> describe distros -> ; +------------------+--------------------------------------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------+--------------------------------------------------+------+-----+---------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | product_id | int(10) unsigned | NO | MUL | NULL | | | compatibility_id | int(10) unsigned | NO | MUL | NULL | | | user_id | int(10) unsigned | NO | | NULL | | | status | enum('pending','published','rejected','removed') | NO | | NULL | | | distro_type | enum('file','url') | NO | | NULL | | | version | varchar(150) | NO | | NULL | | | filename | varchar(50) | YES | | NULL | | | url | varchar(250) | YES | | NULL | | | virus | enum('READY','PASS','FAIL') | YES | | NULL | | | downloads | int(10) unsigned | NO | | 0 | | +------------------+--------------------------------------------------+------+-----+---------+----------------+ 11 rows in set (0.01 sec) mysql> describe downloads; +------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+------------------+------+-----+---------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | product_id | int(10) unsigned | NO | MUL | NULL | | | distro_id | int(10) unsigned | NO | MUL | NULL | | | user_id | int(10) unsigned | NO | MUL | NULL | | | ip_address | varchar(15) | NO | | NULL | | | date | datetime | NO | | NULL | | +------------+------------------+------+-----+---------+----------------+ 6 rows in set (0.01 sec) mysql> describe views -> ; +------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+------------------+------+-----+---------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | product_id | int(10) unsigned | NO | MUL | NULL | | | user_id | int(10) unsigned | NO | MUL | NULL | | | ip_address | varchar(15) | NO | | NULL | | | date | datetime | NO | | NULL | | +------------+------------------+------+-----+---------+----------------+ 5 rows in set (0.00 sec)

    Read the article

  • Identifying and removing null characters in UNIX

    - by fahdshariff
    I have a text file containing unwanted null characters. When I try to view it in I see ^@ symbols, interleaved in normal text. How can I: a) Identify which lines in the file contains null characters? I have tried grepping for \0 and \x0, but this did not work. b) Remove the null characters? Running strings on the file cleaned it up, but I'm just wondering if this is the best way? Thanks

    Read the article

  • Bus Timetable database design

    - by paddydub
    hi, I'm trying to design a db to store the timetable for 300 different bus routes, Each route has a different number of stops and different times for Monday-Friday, Saturday and Sunday. I've represented the bus departure times for each route as follows, I'm not sure if i should have null values in the table, does this look ok? route,Num,Day, t1, t2, t3, t4 t5 t6 t7 t8 t9 t10 117, 1, Monday, 9:00, 9:30, 10:50, 12:00, 14:00 18:00 19:00 null null null 117, 2, Monday, 9:03, 9:33, 10:53, 12:03, 14:03 18:03 19:03 null null null 117, 3, Monday, 9:06, 9:36, 10:56, 12:06, 14:06 18:06 19:06 null null null 117, 4, Monday, 9:09, 9:39, 10:59, 12:09, 14:09 18:09 19:09 null null null . . . 117, 20, Monday, 9:39, 10.09, 11:39, 12:39, 14:39 18:39 19:39 null null null 119, 1, Monday, 9:00, 9:30, 10:50, 12:00, 14:00 18:00 19:00 20:00 21:00 22:00 119, 2, Monday, 9:03, 9:33, 10:53, 12:03, 14:03 18:03 19:03 20:03 21:03 22:03 119, 3, Monday, 9:06, 9:36, 10:56, 12:06, 14:06 18:06 19:06 20:06 21:06 22:06 119, 4, Monday, 9:09, 9:39, 10:59, 12:09, 14:09 18:09 19:09 20:09 21:09 22:09 . . . 119, 37, Monday, 9:49, 9:59, 11:59, 12:59, 14:59 18:59 19:59 20:59 21:59 22:59 139, 1, Sunday, 9:00, 9:30, 20:00 21:00 22:00 null null null null null 139, 2, Sunday, 9:03, 9:33, 20:03 21:03 22:03 null null null null null 139, 3, Sunday, 9:06, 9:36, 20:06 21:06 22:06 null null null null null 139, 4, Sunday, 9:09, 9:39, 20:09 21:09 22:09 null null null null null . . . 139, 20, Sunday, 9:49, 9:59, 20:59 21:59 22:59 null null null null null

    Read the article

  • Wordpress databse insert() and update() - using NULL values

    - by pygorex1
    Wordpress ships with the wpdb class which handles CRUD operations. The two methods of this class that I'm interested in are the insert() (the C in CRUD) and update() (the U in CRUD). A problem arises when I want to insert a NULL into a mysql database column - the wpdb class escapes PHP null variables to empty strings. How can I tell Wordpress to use an actual MySQL NULL instead of a MySQL string?

    Read the article

  • Why does null need to be casted?

    - by BlueRaja The Green Unicorn
    The following code does not compile: //int a = ... int? b = (int?) (a != 0 ? a : null); In order to compile, it needs to be changed to int? b = (a != 0 ? a : (int?) null); Since both b = null and b = a are legal, this doesn't make sense to me. Why does null need to be casted, and why can't we simply cast the whole expression (which I know is legal in other cases)?

    Read the article

  • LINQ-to-entities - Null reference

    - by BlueRaja
    I could swear this was working the other day: var resultSet = (from o in _entities.Table1 where o.Table2.Table3.SomeColumn == SomeProperty select o ).First(); SelectedItem = resultSet.Table2.SomeOtherColumn; I am getting a null reference exception on the last line: resultSet.Table2 is null. Not only am I sure that all the foreign keys and whatnot have the correct values, but I don't see how Table2 could be null, since o.Table2.Table3.SomeColumn == SomeProperty. resultSet is being returned with all its properties set to the correct values, with the exception that Table2 is null.

    Read the article

  • linq null parameter

    - by kusanagi
    how can i do the code static string BuildMenu(List<Menu> menu, int? parentId) { foreach (var item in menu.Where(i => i.ParentMenu == parentId || i.ParentMenu.MenuId == parentId).ToList()) { } } return BuildMenu(menuList,null); so if parentId==null then return only records i = i.ParentMenu == null but when parentId is 0 then return records with i.ParentMenu.MenuId == parentId

    Read the article

  • Identifying and removing null characters in UNIX

    - by fahdshariff
    I have a text file containing unwanted null characters. When I try to view it in I see ^@ symbols, interleaved in normal text. How can I: a) Identify which lines in the file contains null characters? I have tried grepping for \0 and \x0, but this did not work. b) Remove the null characters? Running strings on the file cleaned it up, but I'm just wondering if this is the best way? Thanks

    Read the article

  • Compilers behave differently with a null parameter of a generic method

    - by Eyal Schneider
    The following code compiles perfectly with Eclipse, but fails to compile with javac: public class HowBizarre { public static <P extends Number, T extends P> void doIt(P value) { } public static void main(String[] args) { doIt(null); } } I simplified the code, so T is not used at all now. Still, I don't see a reason for the error. For some reason javac decides that T stands for Object, and then complains that Object does not conform to the bounds of T (which is true): HowBizarre.java:6: incompatible types; inferred type argument(s) java.lang.Number,java.lang.Object do not conform to bounds of type variable (s) P,T found : <P,T>void required: void doIt(null); ^ Note that if I replace the null parameter with a non-null value, it compiles fine. Which of the compilers behaves correctly and why? Is this a bug of one of them?

    Read the article

  • How Oracle 10g evaluates NULL in boolean expressions

    - by Phani Kumar PV
    if not (i_ReLaunch = 1 and (dt_enddate is not null)) How this epression will be evaluated in Oracle 10g when the input value of the i_ReLaunch = null and the value of the dt_enddate is not null it is entering the loop. According to the rules in normal c# and all it should not enter the loop as it will be as follows with the values. If( not(false and (true)) = if not( false) =if( true) which implies it should enters the loop But it is not happening Can someone let me know if i am wrong at any place

    Read the article

  • MessageBroker.getMessageBroker(null) getting null pointer Exception

    - by Shital
    I am creating Dynamic Destinations MessageBroker broker = MessageBroker.getMessageBroker(null); MessageService service = (MessageService) broker.getService("message-service"); MessageDestination destination = (MessageDestination) service.createDestination("Group1"); if (service.isStarted()) { destination.start(); } But I am getting Null Pointer Exception MessageBroker broker = MessageBroker.getMessageBroker(null); Can Anyone Help Me

    Read the article

  • Alter Dilemma : How to use to set Primary and other attributes.

    - by Rachel
    I have following table in database AND I need to alter it to below mentioned schema. Initially I was drop the current database and creating new one using the create but I am not supposed to do that and use ALTER but am not sure as to how can I use ALTER to add primary key and other constraints. Any Suggestions !!! Code Current: CREATE TABLE `details` ( `KEY` varchar(255) NOT NULL, `ID` bigint(20) NOT NULL, `CODE` varchar(255) NOT NULL, `C_ID` bigint(20) NOT NULL, `C_CODE` varchar(64) NOT NULL, `CCODE` varchar(255) NOT NULL, `TCODE` varchar(255) NOT NULL, `LCODE` varchar(255) NOT NULL, `CAMCODE` varchar(255) NOT NULL, `OFCODE` varchar(255) NOT NULL, `OFNAME` varchar(255) NOT NULL, `PRIORITY` bigint(20) NOT NULL, `STDATE` datetime NOT NULL, `ENDATE` datetime NOT NULL, `INT` varchar(255) NOT NULL, `PHONE` varchar(255) NOT NULL, `TV` varchar(255) NOT NULL, `MTV` varchar(255) NOT NULL, `TYPE` varchar(255) NOT NULL, `CREATED` datetime NOT NULL, `MAIN` varchar(255) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; Desired: CREATE TABLE `details` ( `id` bigint(20) NOT NULL, `code` varchar(255) NOT NULL, `cid` bigint(20) NOT NULL, `ccode` varchar(64) NOT NULL, `c_code` varchar(255) NOT NULL, `tcode` varchar(255) NOT NULL, `lcode` varchar(255) NOT NULL, `camcode` varchar(255) NOT NULL, `ofcode` varchar(255) NOT NULL, `ofname` varchar(255) NOT NULL, `priority` bigint(20) NOT NULL, `stdate` datetime NOT NULL, `enddate` datetime NOT NULL, `list` varchar(255) NOT NULL, `name` varchar(255) NOT NULL, `created` datetime NOT NULL, `date` datetime NOT NULL, `ofshn` int(20) NOT NULL, `ofcl` int(20) NOT NULL, `ofr` int(20) NOT NULL, PRIMARY KEY (`code`,`ccode`,`list`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; Thanks !!!

    Read the article

  • Checking instance of non-class constrained type parameter for null in generic method

    - by casperOne
    I currently have a generic method where I want to do some validation on the parameters before working on them. Specifically, if the instance of the type parameter T is a reference type, I want to check to see if it's null and throw an ArgumentNullException if it's null. Something along the lines of: // This can be a method on a generic class, it does not matter. public void DoSomething<T>(T instance) { if (instance == null) throw new ArgumentNullException("instance"); Note, I do not wish to constrain my type parameter using the class constraint. I thought I could use Marc Gravell's answer on "How do I compare a generic type to its default value?", and use the EqualityComparer<T> class like so: static void DoSomething<T>(T instance) { if (EqualityComparer<T>.Default.Equals(instance, null)) throw new ArgumentNullException("instance"); But it gives a very ambiguous error on the call to Equals: Member 'object.Equals(object, object)' cannot be accessed with an instance reference; qualify it with a type name instead How can I check an instance of T against null when T is not constrained on being a value or reference type?

    Read the article

  • R: preventing unlist to drop NULL values

    - by nico
    I'm running into a strange problem. I have a vector of lists and I use unlist on them. Some of the elements in the vectors are NULL and unlist seems to be dropping them. How can I prevent this? Here's a simple (non) working example showing this unwanted feature of unlist a = c(list("p1"=2, "p2"=5), list("p1"=3, "p2"=4), list("p1"=NULL, "p2"=NULL), list("p1"=4, "p2"=5)) unlist(a) p1 p2 p1 p2 p1 p2 2 5 3 4 4 5

    Read the article

  • node to traverse cannot be null (Hibernate SQL)

    - by tiswas
    I'm performing a SQL query through hibernate, which looks like: SELECT thi FROM track_history_items thi JOIN artists art ON thi.artist_id = art.id WHERE thi.type = "TrackBroadcast" GROUP BY art.name ORDER thi.createdAt DESC but I'm getting the message that 'Node to traverse cannot be null!'. Anyone know what could be causing this? --EDIT-- I'm pretty sure that this problem is being caused by the possibility of artist_id to be null. However, I can't prevent this, so can I just skip the rows track_history_item rows which have a null artist_id?

    Read the article

  • SSIS Script Component, Allow Null values

    - by user2471943
    I have a SSIS package that I am programming and my script component won't allow null column inputs. I have checked the box to keep nulls in the flat file source component. My program is running well until my script component where I get the error "The column has a null value" (super vague, I know). The column currently throwing the error is an "int" valued column and is used for aggregations in my script. I could make the null values 0s or to say "NULL" but I'd prefer to just leave them blank. Any advice on how to handle this problem would be greatly appreciated! Thanks in advance! I am using SQL Server BIDS 2008.

    Read the article

  • To "null" or not to "null" my class's attributes

    - by Helper Method
    When I write a class in Java, I like to initialize the attributes which are set to a default value directly and attributes which are set by the caller in the constructor, something like this: public class Stack<E> { private List<E> list; private size = 0; public Stack(int initialCapacity) { list = new ArrayList<E>(initialCapacity); } // remainder omitted } Now suppose I have a Tree class: public class Tree<E> { private Node<E> root = null; // no constructor needed, remainder omitted } Shall I set the root attribute to null, to mark that it is set to null by default, or omit the null value?

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >