Tuesday, March 31, 2009

Leave no room for a lower-level language below C++ (except assembler)

Excerpts from Bjarne Stroustrup’s book “The Design and Evolution of C++”

“To remain a viable systems programming language, C++ must maintain C’s ability to access hardware directly, to control data structure layout, and to have primitive operation and data types that map on to hardware in a on-to-one fashion. The alternative is to use C or assembler. The language design talk is to isolate the low-level features and render them unnecessary for code that doesn’t deal directly with system details. The aim is to protect programmers against accidental misuse without imposing undue burdens.”

Monday, March 30, 2009

fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory

If you are seeing this error, the ISO Standard C++ supports the inclusion of the iostream header as either


#include <iostream>
or
#include "iostream"

Background:

VC has supported two different versions of IOStreams for
several years. "Classic IOStreams", as implemented in <iostream.h> (etc), and "Standard IOStreams", as implemented in <iostream> (etc).

Note the lack of the .h in the standard iostreams header file names.
VC7.0 deprecated the "classic IOStreams" and VC7.1 dropped support for "classic IOstreams" altogether.

Sunday, March 29, 2009

warning C4996: 'getch': The POSIX name for this item is deprecated.

When you come across this error,

Instead of getch(), use the ISO C++ conformant name: _getch().

Saturday, March 28, 2009

error C3861: 'xxx': identifier not found

#include<iostream>
#include<conio.h>
void main()
{
    cls();
    int x=10;
    float y=10.1f;
    char z='a';
    std::cout << "x = " << x << std::endl;
    std::cout << "y = " << y << std::endl;
    std::cout << "z = " << z << std::endl;
    _getch();

}

void cls()
{
    for(int i = 0; i < 50; i++)
        std::cout<<std::endl;
}

While compiling the above program you could get

error C3861: 'cls': identifier not found

The issue when the compiler reads from top to bottom it hasn’t found the declaration of cls() yet.

Moving the cls() function above the main should fix this.

Friday, March 27, 2009

Warning C4305: 'initializing' : truncation from 'double' to 'float'

int x=10;
float y=10.1;
char z='a';
std::cout << "x = " << x << std::endl;
std::cout << "y = " << y << std::endl;
std::cout << "z = " << z << std::endl;

this code will cause a compiler error in 2nd line where the float is declared.

It’s because the numerical literal 3.14159 is a double. Changing it to 10.1f to make it a float should fix this.

float y=10.1f;

or

double y=10.1;

Thursday, March 26, 2009

Difference between cout and std::cout?

When you use std:: before cout you are telling the compiler that you want to use the name cout that is in the namespace called standard. There are lots of ways you can do it.

1)

CODE

#include <iostream>
int main()
{
using std::cout; using std::endl;
    cout << "Hello, world" << endl;
return 0;
}

2)

CODE

#include <iostream>
using namespace std;
int main()
{
    cout << "Hello, world" << endl;
return 0;
}

3)

CODE

#include <iostream>
int main()
{
    std::cout << "Hello, world" << std::endl;
return 0;
}

It is just a matter of personal style. I personally use number 1.
But using it this ay you have to remember all the names that you wish to use and say that you want to use them. Only the names in that scope can use them.

Wednesday, March 25, 2009

Base Member Hiding in C++

Base class specifiers are explained in my previous blog. Here we will see how we could hide existing functionalities in a base class because in C++, it is not possible to remove functionality from a class.

Following code snippet from LearnCpp.com is used to explain this concept.

Base Class:

class Base  

{  

private:  

int m_nValue;  

 

public:  

    Base(int nValue)  

        : m_nValue(nValue)  

    {  

    }  

 

protected:  

void PrintValue() { cout << m_nValue; }  

}; 

Derived Class:

class Derived: public Base  

{  

public:  

    Derived(int nValue)  

        : Base(nValue)  

    {  

    }  

 

// Base::PrintValue was inherited as protected, so the public has no access

// But we're changing it to public by declaring it in the public section

    Base::PrintValue;  

}; 

This means the following code will work, as PrintValue is declared as public in the derived class.

int main()
{
    Derived cDerived(7);

    // PrintValue is public in Derived, so this is okay
    cDerived.PrintValue(); // prints 7
    return 0;
}

Conversely, here is another example where the code doesn’t work because of the Base Member variable is hidden as private in the derived function.

class Base
{
public:
    int m_nValue;
};

class Derived: public Base
{
private:
    Base::m_nValue;

public:
    Derived(int nValue)
    {
         m_nValue = nValue;
    }
};

int main()
{
    Derived cDerived(7);

    // The following won't work because m_nValue has been redefined as private
    cout << cDerived.m_nValue;

    return 0;
}

Tuesday, March 24, 2009

How to create a XPS document

XPS Viewer is the Microsoft version of Adobe Acrobat reader. It doesn’t have the edit functionality like the PDF files quite yet.

If you are wondering how to create a XPS document, here is how you do it.

1. Open the Word/Text file you want to create it in to a XPS file

2. Select File –> Print and select XPS Document Writer from the options

Monday, March 23, 2009

International themes in Windows 7

There are some hidden International themes in Windows 7 that can be accessed in this path,

%WinDir%\Globalization\MCT

There are some custom themes for Australia, Canada, UK, US and South Africa. Includes a complete themes suite, with wallpapers, sound themes etc…

Sunday, March 22, 2009

Browser settings to launch your favorite websites in tabs every time you launch them.

Internet Explorer

If you want the browser to open some of your favorite websites every time you launch them,

1. Go to tools and select Internet options

2. Type all the sites you want to navigate to under Home page tab.

Firefox

Go to Tools –> Options and in Home page section type all the web pages you want to open in tabs separated by the pipe key ( | ) which can be invoked by Shift + backslash.

Chrome

Tools –> Options will provide options to Add new tabs.

Technorati Tags:

del.icio.us Tags:

Saturday, March 21, 2009

Password protecting files in XP and Windows Vista

XP

1. Select the folder you want to Encrypt and right click and Send To –---> Compressed Zipped folder.

2. This would create a Compressed folder with the same name, now open the folder by Right clicking on the folder and selecting Explore.

3. Go to the File menu and choose Add a password.

To remove the password in Step 3, go to the File menu and select Remove the password.

Vista

In Vista Ultimate version:

Right click any folder and go to the General tab and select the Advanced button.

Check the box next to Encrypt contents to secure data.

Un-checking would remove the encryption as well

Other versions of Vista:

Encrypt files utility is a free ware that allows you to encrypt and password protect your files

If you just want to password protect your files, Password protect software is free for 30 days.

Friday, March 20, 2009

Bread crumb bar changes to Windows 7 RC

As mentioned in E7 blog now the parent folder would not collapse to a overflow drop down, shows the parent folder instead.

I'm really excited about this change, resolved a lot of confusion around navigating to the parent folder.

Fig 1.

In Beta, a parent folder would collapse into an overflow dropdown

beta parent folder

Fig 2.

In RC, parent folders always remain within single click access

RC parent folder

del.icio.us Tags:

Technorati Tags:

Thursday, March 19, 2009

Overriding and Virtual Function Matching

A virtual function could only be overridden by a function in a derived class with the same name and exactly the same argument and return type.

This avoided any form of run-time type checking of arguments and any need to keep more extensive type information around at run time.

class Base
{

public:
    virtual void f();   
    virtual void g(int);
};

class Derived : public Base
{
public:
    void f(int); //overrides Base::f()
    void g(char); //doesn't override Base::g()
};

Wednesday, March 18, 2009

Virtual functions in C++

The key implementation in Stroustrup’s C with classes (C++ early form) was that the set of virtual functions in a class defines an array of pointers to functions so that the call of a virtual function is simply an indirect function call through that array.

class A
{
    int a;
public:
    virtual void f();   
    virtual void g(int);
    virtual void h(double);   
};

class B : public A
{
public:
    int b;
    void g(int); //overrides A::g()
    virtual void m(B*);
};

class  B is derived from class A and class A is the base class of class A

 

Tuesday, March 17, 2009

Work Environment at Bell Labs during Evolution of C++

As explained by Bjarne Stroustrup the work environment that inculcated and propelled the Evolution of C++. This is the way any research firm should function.

“The absence of a formal organizational structure, of larger-scale support in terms of money, people, “captive” users, and marketing was more than compensated for by the informal help and insights of my peers in CSRC and the protection from nontechnical demands from development organization offered by the center management.

It was also important that Bell Labs provided an environment where there was no need to hoard ideas for personal advancement.

Instead, discussion could, did, and still does flow freely, allowing people to benefit from ideas and opinions of others.”

-Stroustrup

Technorati Tags: ,
del.icio.us Tags: ,

Monday, March 16, 2009

Newly installed programs shows up at the bottom of Start Menu, in Windows 7 RC build

This is a great change in finding newly installed programs in the App Programs list, now newly installed programs temporarily show up in the bottom of the Start Menu.

Sunday, March 15, 2009

Alt + Tab changes to Windows 7 RC

Aero Peek has been given an extension by implementing in in Alt + Tab window.

Now Aero Peek will appear in Alt + Tab windows.

 

 

 

 

 

 

 

 

 

Img source: MSDN E7 Blog.

Saturday, March 14, 2009

System Repair Disc to the rescue in Windows 7

Windows 7 beta has an in-build System Repair Disc to use to boot to the system recovery options if you don't have a Windows installation disc, can't find your Windows installation disc, or can't access the recovery options provided by your computer manufacturer.

1. Create a System Repair Disc can be found under All Programs –> Maintenance or by typing recdisc.exe in the start menu search

2. Insert a blank CD or DVD and click on Create Disc button

image

3. Once its done, remove and label your new Windows 7 System Repair Disc

del.icio.us Tags:

Technorati Tags:

Friday, March 13, 2009

Windows Movie maker

Windows movie maker is removed from Windows and moved to Windows Live Essentials suite of tools. It has great simplified tools that offers full-fledged options for an average home user by getting rid of some features from older versions.

image

Windows Movie Maker can be downloaded here

Technorati Tags:

del.icio.us Tags:

Thursday, March 12, 2009

ISO burning made so easy in Windows 7 beta

When you double click on an .iso image you get the following dialog to burn the ISO image.

You can burn an ISO image to disk with this built-in utility in Windows 7.

Wednesday, March 11, 2009

ClearType Text Tuning and Display Color Calibration in Windows 7 beta

Check out cttune.exe and dccw.exe respectively, or run the applets from Control Panel for your laptops or HDTV to display a very crisp image than it did before.

It’s amazing what a difference this makes by slightly darkening the color of the text and adjusting the gamma back a little.

Tuesday, March 10, 2009

Windows Vista-Style Taskbar in Windows 7 beta

It takes a while to get used to the Windows 7 beta styled taskbar, for those who really would prefer a look more reminiscent of Windows Vista here is a quick way to do it.

Right-click on the taskbar and choose the properties dialog. Select the “small icons” checkbox and under the “taskbar buttons” setting, choose “combine when taskbar is full”. It’s not pixel-perfect in accuracy, but it’s close from a functionality point of view.

del.icio.us Tags: ,,

Technorati Tags: ,,

Monday, March 9, 2009

Jump lists in Windows 7 beta

Jump lists replace the default right-click context menu in the new taskbar.
You can also access them by left-clicking and dragging up in a kind of “swooshing” motion. This is particularly useful if you’re running Windows 7 on a one-button MacBook.

Another place where you can “swoosh” (as Tim Sneath like to call it and not an official Microsoft term), is the IE 8 address bar, where the downward drag gesture brings up an expanded list containing the browser history, favorites and similar entries. The slower you drag, the cooler the animation!

Technorati Tags:

del.icio.us Tags:

Sunday, March 8, 2009

Problems Steps Recorder in Windows 7 beta

Problems Steps Recorder is a very neat tool as part of the in-built diagnostic tools that could be used to send feedback on the product, the Problem Steps Recorder provides a simple screen capture tool that enables you to record a series of actions.

Once you click the “Record” button this tool tracks your mouse and keyboard actions and captures screen shots of the Windows explorer and generates a HTML-based slideshow of the steps.

You can access this tool by clicking on Select feedback shortcut from the desktop or type psr.exe in the start menu search box.

del.icio.us Tags:

Technorati Tags:

Saturday, March 7, 2009

Extended Context menu: Open Command Window here and Copy as path

Here is a cool tip in your Windows Vista and in Windows 7 beta to open a new command prompt from a folder and copying the path of a file using your extended context menu options.

Open Command window here

Shift+Right-click on a folder enables Extended context menu and select Open command window here

Copy as path

Shift+Right-click on a folder to select Copy as path to share out the file path. If a folder or file is shared it copies the network share path to your clip board.

Technorati Tags:

del.icio.us Tags:

Friday, March 6, 2009

Windows 7 Beta, Windows Mobility Center

Laptop users will appreciate the new enhancements to quickly the most commonly used laptop settings, such as brightness, volume, battery status, and wireless network status.

Pressing Win+X would let you access the Windows Mobility Center.

Different tiles are displayed depending on your system and your configuration.

del.icio.us Tags:

Technorati Tags:

Thursday, March 5, 2009

Windows 7 Beta Display enhancements

Projecting in Windows 7 beta is really quick and simple. Pressing Win+P would give you the following pop-up menu.

The Win+P Projector Settings window allows you to quickly switch display settings.

Use the arrow keys (or keep pressing Win+P) to switch to “clone”, “extend” or “external only” display settings. You can access the application from displayswitch.exe

If you want broader control over presentation settings, you can also press Win+X to open the Windows Mobility Center, which allows you to turn on a presentation “mode” that switches IM clients to do not disturb, disables screensavers, sets a neutral wallpaper etc. (Note that this feature is also available in Windows Vista.)

del.icio.us Tags:

Technorati Tags:

Wednesday, March 4, 2009

Analyze your energy consumption in realtime using Google Powermeter

Google PowerMeter, a tool designed to provide consumers with information about their home energy usage in real time. Powermeter is still in prototype, and not yet available to the public, will be free for both private and commercial use.

This tool will receive information from utility smart meters and energy management devices and provide anyone who signs up access to her home electricity consumption right on her iGoogle homepage.

The graph from Google’s website shows how someone could use this information to figure out how much energy is used by different household activities.

image

Technorati Tags:

del.icio.us Tags:

Tuesday, March 3, 2009

Deep search Craigslist using CraigsList Readder

CraigsList Reader is a Windows only software that lets you can search every listing in every city, fine-tuned by region, state, and city across different categories.

You can drill down to search just for jobs, jobs by type, items for sale, items with pictures, price ranges.

You can set up desktop notifications based on specific search variables and it will check the site at given time interval.

Technorati Tags:

del.icio.us Tags:

Monday, March 2, 2009

Sync your Bookmarks or Favorites across Browsers

There are plenty of options available to sync your bookmarks/favorites across browsers and across multiple computers, here are a few that I would recommend that works great.

For IE, Firefox and Safari users we have Foxmarks, a free browser add-on that syncs and backs up your bookmarks across multiple computers and more.

If you are a Chrome or Opera user, Delicious helps seamless syncing across all browsers and has handy bookmark bar tools for reading and saving bookmarks from any browser.

Live Favorites lets you import or export tags and lets you organized with folders or tags, also works great across browsers.

del.icio.us Tags:
Technorati Tags:

Sunday, March 1, 2009

Best ways to Backup your data

Hard Drive 101: Hard Drives WILL crash, your data is in DANGER. It’s smart to backup your data before it crashes.

We are going to see few options to backup your data,

1. External Hard drives:

It’s not really smart to back on the same drive which you are planning to backup. Here are some good External Hard drive backup solutions:

*Clickfree portable backup: Offers easy automatic backup

Hard drive enclosures: If you have an old external hard drive, you can use an enclosure and use it as a backup disk.

Drobo offers a solution to rack up multiple spare hard drives in RAID. This redundancy backs up your data when your hard drive and a backup hard drive crashes.

Software's to backup:

Time Machine: Mac users can use this neat inbuilt tool.

*Cobian Backup is an automated backup program for Windows users.

*Windows users can also use the Build-in Vista backup utility.

2. Network attached storage

Network attached storages are large hard drives usually attached to a router where multiple computers can back up to.

Time Capsule, is the wireless network-attached storage for Mac users

Addonics NAS adapter, can convert any USB external hard drive to a network drive.

Drobo Droboshare, is another alternative for NAS

*Synology Diskstation, you can put your hard drive in it and it becomes a NAS. It also has the capability to communicate with XBOX 360 and PS3.

3. Online backup

This is the easiest option if you have the network capability.

Mobile me, is available for Mac users, offers 60 GB of network storage, but it’s kind of expensive.

*Carbonite, offers simple online backup solutions, $49 per year.

Drop box, available at box.net offers files backup.

Microsoft Mesh, a free service, still available as Beta service offers 5 GB can sync up several computers.

Skydrive offers  25 GB of free service from Microsoft, works with Mac too, uses Active sync to backup your data.

*Jungle disk is the favorite choice for most uesrs, offers $15c per GB with no monthly fee.

Technorati Tags:

del.icio.us Tags: