|
For instance why does most members in STL implementation have M or _ or __ prefix? Why there is so much boilerplate code ?
What features C++ is lacking that would allow make vector (for instance) implementation clear and more concise?
Started by Ćukasz Lew on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
For example one could define a macro called Type and then include <vector> , if... .
Such names are reserved in C++.
Implementatons use names starting with underscore and a capital letter or two underscores to avoid confilcts with user defined macros .
|
|
Template<class T> class Set { public: void insert(const T& item); void remove(const T& item); private: std::list<T> rep; } template<typename T> void Set<T>::remove(const T& item) { typename std::list<T>::iterator it = // ...
Started by Jinx on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
You could specialize your remove function for ints....
I think in general you need both the typename/class T in the class declaration as well as function definitions because you can define full/partial template specifications for function definitions .
|
|
Using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { A[] a = new A[10]; } } public class A { static int x; public A() { System.Console.WriteLine...
Started by Sunil on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
You....
A[] a = new A[10]; will only create an array that can hold 10 instances of A , but the references are initialized to null .
They are containers of the type at hand, not actual objects of the type .
Arrays by default are initialized with null values.
|
Ask your Facebook Friends
|
I'm trying to work on a Rails site here in it's development environment, where I want to test email delivery, and I can't work out why properties declared in the main environment.rb aren't being overwritten by the more specific development.rb file that...
Started by Chris Adams on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
This should work:
config.action_mailer.smtp_settings = { :address => 'smtp.some_host.com', :port => 25, :domain => 'developmentdomain.net', :authentication => :login, :user_name => 'blabla', :password => "some_pass" }
To set the configuration... .
|
|
Is it better to answer it focusing on why the company is good, or how the job will affect you personally? (ie: by gaining experience and growing)
Also, I never feel I answer correctly when they tell me to "tell them about myself", what should one focus...
Started by Juan Manuel Formoso on
, 15 posts
by 15 people.
Answer Snippets (Read the full thread at stackoverflow):
If you want to work here," not "why do you want to be employed here," and I think it's always a good idea you want to work....
If you want experience, say so.
Is to the "why do you want to work here" question, be honest.
|
|
Def divideset(rows, column, value) split_function = nil if value.is_a?(Fixnum) || value.is_a?(Float) split_function = lambda{|row| row[column] >= value} else split_function = lambda{|row| row[column] == value} end set1 = rows.select{|row| split_function...
Started by uzo on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Here are some rather minor "style.
Verbosity and clunkiness we could just write everything in Java.. .
|
|
Inspired by this question ,
Now visible only for users with > 10k rep
I came up with the following code:
$cat loop.c int main( int argc, char ** argv ) { int i = 0; while( i++ < 2147483647 ); } $cc -o loop loop.c $ time ./loop real 0m11.161s user...
Started by Oscar Reyes on
, 12 posts
by 12 people.
Answer Snippets (Read the full thread at stackoverflow):
There are some things you need to control for here:
the startup of the JVM is nontrivial compared that JIT compilers often produce better code than a non-optimised C compiler "What I'm missing here with the other answers here that....
|
|
Hi guys,
I'm doing some work in Actionscript 2.0 for the first time in a while (really simple stuff, just pulling content from a text file), and I can not fathom for the life of me why I'm getting such unpredictable output here.
Sometimes when I test ...
Started by Chris Adams on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
There are possibly some scope issues here, but I just can't see how.
Global only if strictly necessary.
|
|
I am looking into someone else's code and do not have much experience with anything to do with multi-threading. I came across this line of code:
BeginInvoke((MethodInvoker)delegate() { btnCalibrate.PerformClick(); });
I was wondering why do this when ...
Started by aip.cd.aish on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Making the call or even lockup the application, so BeginInvoke is the better choice here.
|
|
A while ago, I asked a question about $ , and got useful answers -- in fact, I thought I understood how to use it.
It seems I was wrong :(
This example shows up in a tutorial:
instance Monad [] where xs >>= f = concat . map f $ xs
I can't for the...
Started by J Cooper on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
I'd like....
Map f ) and then apply it to its argument ( xs it seems to me to be a lot clearer .
Another way here is to first construct a function ( concat .
The $ is used here because it has lower precedence than normal function application.
|