August 19, 2011

Profiling tools for Linux

Some profiling tools on Linux

http://valgrind.org/

http://www.cs.utah.edu/dept/old/texinfo/as/gprof_toc.html

http://oprofile.sourceforge.net/about/

http://perfinsp.sourceforge.net/#Overview

Guide to porting from Solaris to Linux on x86

Solaris is considered one of the closest flavors of UNIX® to Linux™, but for migration purposes, there can be differences between the two in the areas of memory mapping, threading, or natural language support (to name just a few). This porting guide gives you advice on planning for the port to Linux/x86, and helps you understand the differences in the development environment and architecture.

http://www.ibm.com/developerworks/linux/library/l-solar/

June 16, 2011

STL containers

What are the types of STL containers?


• deque

• hash_map

• hash_multimap

• hash_multiset

• hash_set

• list

• map

• multimap

• multiset

• set

• vector



Sequence containers are: vector deque list

Associative containers are: set multiset map and multimap.

Containers adapters: stack queue and priority_queue.

No hash containers are defined in the current C++ STL standard. However other STL implementation might have some hash based containers (ie STL SGI implementation).



The primary idea in the STL is the container (also known as a collection), which is just what it sounds like: a place to hold things. You need containers because objects are constantly marching in and out of your program and there must be someplace to put them while they’re around. You can’t make named local objects because in a typical program you don’t know How many, or what type, or the lifetime of the objects you’re working with. So you need a container that will expand whenever necessary to fill your needs. All the containers in the STL hold objects and expand themselves. In addition, they hold your objects in a particular way.

A vector is a linear sequence that allows rapid random access to its elements. However, it’s expensive to insert an element in the middle of the sequence, and is also expensive when it allocates additional storage. A deque is also a linear sequence, and it allows random access that’s nearly as fast as vector, but it’s significantly faster when it needs to allocate new storage, and you can easily add new elements at either end (vector only allows the addition of elements at its tail). A list the third type of basic linear sequence, but it’s expensive to move around randomly and cheap to insert an element in the middle. Thus list, deque and vector are very similar in their basic functionality (they all hold linear sequences), but different in the cost of their activities. So for your first shot at a program, you could choose any one, and only experiment with the others if you’re tuning for efficiency.

All three have a member function push_back( ) which you use to insert a new element at the back of the sequence (deque and list also have push_front( )).

An iterator is a class that abstracts the process of moving through a sequence. It allows you to select each element of a sequence without knowing the underlying structure of that sequence.This is a powerful feature, partly because it allows us to learn a single interface that works with all containers, and partly because it allows containers to be used interchangeably.



class Shape {

public:

virtual void draw() = 0;

virtual ~Shape() {};

};

class Circle : public Shape {

public:

void draw() { cout << "Circle::draw\n"; }

~Circle() { cout << "~Circle\n"; }

};

class Triangle : public Shape {

public:

void draw() { cout << "Triangle::draw\n"; }

~Triangle() { cout << "~Triangle\n"; }

};

class Square : public Shape {

public:

void draw() { cout << "Square::draw\n"; }

~Square() { cout << "~Square\n"; }

};

typedef std::vector Container;

typedef Container::iterator Iter;

int main() {

Container shapes;

shapes.push_back(new Circle);

shapes.push_back(new Square);

shapes.push_back(new Triangle);

for(Iter i = shapes.begin();

i != shapes.end(); i++)

(*i)->draw();

// ... Sometime later:

for(Iter j = shapes.begin();

j != shapes.end(); j++)

delete *j;

} ///:~



November 15, 2009

Interview questions

Explain DDX and DDV in MFC
CmdTraget Class in MFC
SendMessage and Post Message in MFC
CObject Class in MFC
Can we use Free with new or delete with Malloc ?
how to define const data type in C++ class
CArchive Class in MFC
which is the Base of all MFC classes?
blocking function in socket
How to define or declare static in class
safe array
smart pointer

November 14, 2009

Unit testing native (C/C++) code on Windows

"WinUnit offers a unique approach to unit testing native (C/C++) code on Windows."


November 13, 2009

September 16, 2009

Detecting memory leaks in C++

References from C++ Professionals group on LinkedIn.

http://www.research.att.com/~bs/bs_faq2.html#memory-leaks
http://www.boost.org/doc/libs/1_40_0/libs/smart_ptr/smart_ptr.htm
http://www.hpl.hp.com/personal/Hans_Boehm/gc/
http://www.flipcode.com/archives/Presenting_A_Memory_Manager.shtml
http://duma.sourceforge.net/
http://www.andreasen.org/LeakTracer/
http://perens.com/FreeSoftware/ElectricFence/
http://valgrind.org/

May 4, 2009

Free and Open Source Software Portal

The UNESCO Free and Open Source Software Portal at http://www.unesco-ci.org/cgi-bin/portals/foss/page.cgi?d=1 explains how we can make better use of its resources.

March 5, 2009

Visual Studio Gallery

A collection of products and extensions for MS Visual Studio.

http://www.visualstudiogallery.com/

February 17, 2009

Web service testing tool

Try soapUI..
Explore here http://www.soapui.org/

Apache JMeter,

Web services in C++

Wondering how to implement web services in C++ applications?

Try gSOAP toolkit.
http://www.cs.fsu.edu/~engelen/soap.html
http://gsoap2.sourceforge.net

"With the introduction of the Windows Web Services (WWS) API, C++ developers no longer have to think of themselves as second-class citizens in the world of Web Services."


Visual Memory Leak Detector

This one really helped me ...try this for yourself....

http://www.codeproject.com/KB/applications/visualleakdetector.aspx

Free SSL/TLS toolkit

http://www.openssl.org/

"The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a full-strength general purpose cryptography library. "

October 14, 2008

Interview Questions

1)++i=i++ and i++=++i

2)Features of OOPS

3)Initilizaion List in C++

4)Types of Constructors

5)return type of constructor

6)copy constructor and assignment opertrator

7)Explicit constructor

8)Mutable keyword

9)Use of extern

10)Casting Dynamic cast and static cast

11)difference in mutable and static cast

12)Type of overloading

13)Virtual function

14)use of VTable

15)Abstract Class

16)destructor be virtual?

17)volatile qualifier

18) SafeArrays

19)Object Slicing

20)Polymorphic class

21)A persistent varible

22) Size of class with declaration of virtual function and without declaration of any function

23) #Pragma

24)Inline and Macro


=============================


STL

Vectors
List
Deque
Sets
MAp

Dynamic Function with Argument like printf

What is the difference between a ‘thread’ and a ‘process’?

How to prevent memory leaks


=================================


Two processes can share memory in a number of ways.

1. Memory-mapped files
2. Shared memory segments
3. Message queues
4. Named pipes


what is OSI model and Layer of Model


IPC mechanisms are supported by Windows:

Clipboard ,COM ,Data Copy ,DDE ,File Mapping ,Mailslots ,Pipes ,RPC ,Windows Sockets .

type of pipes
type of socket
type of protocol
version of protocol
method in client side and method of server side

what is COM and DCOM
basic method of COM
WMI Process

====================================================================================
MFC


what do mean by AFX

Model and modelless dialog how to create

Document/View Articture

difference between DDE/DDX

September 8, 2008

July 30, 2008

C++ References

Some more reference sites.

C++ reference: http://www.cppreference.com/
Other language references: http://www.cppreference.com/links.html

Eclipse C/C++ Development Tooling - CDT

The CDT (C/C++ Development Tools) Project provides a fully functional C and C++ Integrated Development Environment (IDE) for the Eclipse platform.

Take a look,

http://www.eclipse.org/cdt/

July 28, 2008

10 Commandments for C Programming

10 Commandments for C Programming by Henry Spencer
(Dated but still relevant advice on C Programming)

http://cplus.about.com/od/learningc/a/10-commandments.htm