Posts

c++ - Array of different objects -

alright trying this. i have account class, have checkingaccount , savingsaccount class inherit account class. in program have array called accounts. going hold objects of both types of accounts. account** accounts; accounts = new account*[numaccounts]; accountfile >> tempaccountnum >> tempbalance >> temptransfee; checkingaccount tempaccount(tempbalance, tempaccountnum, temptransfee); accounts[i] = tempaccount; i error when trying assign tempaccount accounts array. no suitable conversion function "checkingaccount" "account" exists. how make accounts array hold both kinds of objects? each element in accounts account* . is, "pointer account ". you're trying assign account directly. instead, should taking address of account: accounts[i] = &tempaccount; remember pointer pointing @ invalid object once tempaccount has gone out of scope. consider avoiding arrays , pointers. unless have reason not to, us...

underscore.js - Group objects by property in javascript -

how convert this: [ {food: 'apple', type: 'fruit'}, {food: 'potato', type: 'vegetable'}, {food: 'banana', type: 'fruit'}, ] into this: [ {type: 'fruit', foods: ['apple', 'banana']}, {type: 'vegetable', foods: ['potato']} ] using javascript or underscore assuming original list contained in variable named list : _ .chain(list) .groupby('type') .map(function(value, key) { return { type: key, foods: _.pluck(value, 'food') } }) .value();

c# - Are the SmtpClient.SendMailAsync methods Thread Safe? -

the smtpclient class states instance members not thread safe. can seen if concurrent calls made send or sendasync . both methods throw invalidoperationexception on second call if first has not yet completed. the method sendmailasync , introduced in .net 4.5, not list invalidoperationexception thrown exception. new .net 4.5 methods implement sort of queuing? reflector isn't able shed light on implementation details of class, assume has been implemented in native methods. can multiple threads call sendmessageasync method on shared instance of smtp client safely? i'm not sure why using reflector didn't work you. if decompile it, see following code: [hostprotection(securityaction.linkdemand, externalthreading=true)] public task sendmailasync(mailmessage message) { taskcompletionsource<object> tcs = new taskcompletionsource<object>(); sendcompletedeventhandler handler = null; handler = delegate (object sender, asynccompletedeventa...

javascript - Iterating over parent elements -

i have html looks (sample 1): <tr id="q_19030" class="q_grid " style="background: none repeat scroll 0% 0% yellow;"> <a class="reset-button" data-question-id="g_1363"></a> </tr> i have html looks (sample 2): <fieldset id="q_19044" class="q_default " style="background: none repeat scroll 0% 0% yellow;"> <a class="reset-button" data-question-id="q_19044"></a> </fieldset> i have jquery code this: $(document).ready(function() { $('.surveyor_radio').parent().parent().append('<a class="reset-button">reset</a>'); $('.reset-button').click(function () { $('#'+$(this).data('question-id') + ' input[type="radio"]:checked').prop('checked', false).trigger('change'); }); $('fieldset').each(function () { var qid = ...

c++ - Maximum value for unsigned int -

this question has answer here: testing maximum unsigned value 6 answers here's want: unsigned int max_unsigned_int_size; max_unsigned_int_size = ???; how should this? c #include <limits.h> unsigned int max_unsigned_int_size = uint_max; c++ #include <limits> unsigned int max_unsigned_int_size = std::numeric_limits<unsigned int>::max();

text - Reading a part of a txt file in VB.NET -

i need read txt file part part... example, in txt file: (age,5char_name) 17susan23wilma25fredy i need read firstly 17susan . in other words, first 7 characters , after 23wilma , 25fredy , i'm not reading whole file , substring file record. there way via streamreader? records 7 bytes... 2 bytes age, 5 bytes name , records in line. there no jump next line. i think there solution: dim filestream new filestream("\records.txt", filemode.open) dim streamreader new streamreader(fs) dim buffer(7) char bw.readblock(buffer, 0, 7) console.writeline(buffer) this read first 7.. can read other via loop or for..

mysqli - Multiple MySQL access blocked using PHP but not MySQL locked -

i have upload location users can update portion of database uploaded file. files 9gb, inserting 150,000,000 lines can take few minutes. after clicking button on website update database, php (using mysqli) goes on mysql lock down. if open other tabs, nothing until large update complete. however, know it's not locking database/table, because cli can still "select count(*) table" , gives me result right away. what best method of inserting 150,000,000 records while still letting other php pages access db (for reading only)? you can use "insert delayed". delayed option insert statement mysql extension standard sql useful if have clients cannot or need not wait insert complete. common situation when use mysql logging , periodically run select , update statements take long time complete. you can read resource on official documentation here . ;-)