echo '' ;

C++

Inline function.


Difference between class and object.

Class

  • Class is a blueprint  with entities and Attributes
  • Class is a template of Objects
  • Class is a blueprint  and Object is a mirror image of class

Object

  • Objects – is a an instance for a class


C++ Example Programs

Here table table you can find many C++ examples.

Shell Sort.cpp

IP to Hex Convertor

// C++ program for IP to hexadecimal conversion 
#include <arpa/inet.h> 
#include <iostream> 
#include <string.h> 
using namespace std; 

// function for reverse hexadecimal number 
void reverse(char* str) 
{ 
	// l for swap with index 2 
	int l = 2; 
	int r = strlen(str) - 2; 

	// swap with in two-2 pair 
	while (l < r) { 
		swap(str[l++], str[r++]); 
		swap(str[l++], str[r]); 
		r = r - 3; 
	} 
} 

// function to conversion and print 
// the hexadecimal value 
void ipToHexa(int addr) 
{ 
	char str[15]; 

	// convert integer to string for reverse 
	sprintf(str, "0x%08x", addr); 

	// reverse for get actual hexadecimal 
	// number without reverse it will 
	// print 0x0100007f for 127.0.0.1 
	reverse(str); 

	// print string 
	cout << str << "\n"; 
} 

// Driver code 
int main() 
{ 
	// The inet_addr() function convert string 
	// in to standard IPv4 dotted decimal notation 
	int addr = inet_addr("127.0.0.1"); 

	ipToHexa(addr); 

	return 0; 
} 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.