Rcjp's Weblog

C++

******* WORK IN PROGRESS ******

Vectors

e.g.::

    names.push_back() 
    names.pop_back() 
    names.at(i) // checks if i is in bounds 
    for(vector<string>::size_type i=0; i<names.size(); ++i) 
    for(vector<string>::const_iterator i=names.begin(); i!=names.end(); ++i) 
    for(vector<string>::const_iterator i=names.begin(); i!=names.end(); ++i) 
    names.empty() 
    names.clear()

Streams

To speed things up if not using printf etc. do.. std::ios_base::sync_with_stdio (false);

Precision::

#include
#include
#include

using namespace std;

int
main()
{
const double pi = std::atan2(1.0, 1.0)*4.0;
cout << " pi = " << pi << endl; cout.setf(std::ios::fixed, std::ios::floatfield); cout.precision(20); cout << " pi = " << pi << endl; for (int i = 1; i <= 10; i++) { cout << std::fixed << std::setprecision(i) << " pi = " << pi << endl; } } [/sourcecode]

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: