சி++

கட்டற்ற கலைக்களஞ்சியமான விக்கிப்பீடியாவில் இருந்து.
(C++ இலிருந்து வழிமாற்றப்பட்டது)
தாவிச் செல்லவும்: வழிசெலுத்தல், தேடல்
C++
C plus plus book.jpg
நிரல்மொழி வகை: multi-paradigm
தோன்றிய ஆண்டு: 1985
உருவாக்குநர்: பியார்னே இசுற்றூத்திரப்பு
Typing discipline: Type system#Static typing, Type system#Safely and unsafely typed systems, Nominative type system
முதன்மைப் பயனாக்கங்கள்: {{{நடைமுறைப்படுத்துவோர்கள்}}}
Dialects: ISO/IEC C++ 1998, ISO/IEC C++ 2003
பிறமொழித்தாக்கங்கள்: சி, Simula, அடா 83, ALGOL 68, CLU, ML
இம்மொழியினால் ஏற்பட்ட தாக்கங்கள்: அடா 95, சி ஷாப், ஜாவா, பிஎச்பி, D, Aikido

சி++ சியின் மேம்பாடுகளைக் கொண்ட ஓர் பொதுவான நிரலாக்கல் மொழியாகும். இது மேல் நிலை நிரலாக்கம் (High Level Programming) மற்றும் வன்பொருட்களை கையாளும் கீழ்நிலை நிரலாக்கம் ஆகிய இரண்டையும் ஆதரிப்பதால் இது ஓர் இடை நிலை மொழியாகும். இம்மொழியில் நிரலாக்க வரிகள் இவ்வாறுதான் வரவேண்டும் (அதாவது இந்தவரியில் இந்த நிரலாக்கம் தான் என்று கோபால் நிரலாக்க மொழி போன்ற கட்டுப்பாடுகள் ஏதும் கிடையாது. பொதுவாக சி++ நிரல்கள் கம்பைல் செய்யப்படும். இவ்வாறு கம்பைல் செய்யப்படும்போது அக்கணினியை இலக்கு வைத்த இயந்திரமொழிக்குக் கொண்டுவரப்படும்.) சி++ மொழி 1980 ஆம் ஆண்டு தொடக்கத்தில் ஏடீ & டீ பெல் ஆய்வுக் கூடத்தில் பியார்னே இசுற்றூத்திரப்பு என்பவரால் உருவாக்கப்பட்டது.

அமெரிக்க பெல் ஆய்வுக்கூடத்தில் பணியாற்றிய பியார்னே இசுற்றூத்திரப்பு சியை மேம்படுத்தும் முகமாக 1979 ஆம் ஆண்டில் வகுப்புகளுடன் கூடிய சி (C with Classes) ஆக விருத்தி செய்தார். இது 1983 ஆம் ஆண்டில் சி மொழியில் வரும் ++ ஆனது increment operator ஐக் குறிக்கும் வகையில் இதுவும் சி++ என மாற்றப்பட்டது.

பொருளடக்கம்

மொழி அமைப்பு [தொகு]

தரவு இனங்கள் [தொகு]

  • void -
  • char - character
  • int - integer
  • float - floating point number
  • double - double precision float
  • bool - Boolean value, true or false
  • wchar_t - wide character

பெயர் வெளி [தொகு]

மாறிலிகள் [தொகு]

செயற்குறிகள் [தொகு]

உலகே வணக்கம் [தொகு]

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


அடிப்படை உள்ளீடும் வெளியீடும் [தொகு]

வெளியீடு [தொகு]

  char *name="John";
  char *country="India";
 
  cout << "Hello, I am " << name << ". I am from "<< country << endl;

உள்ளீடு [தொகு]

# include <iostream>
using namespace std;
 
int main ()
{
  int i;
  cout << "Please enter an integer value: ";
  cin >> i;
  cout << "The value you entered is " << i;
  cout << " and its squre  is " << i*i << ".\n";
  return 0;
}
Please enter an integer value: 5
The value you entered is 5 and its square is 25.


கட்டுப்பாடு [தொகு]

எனில்/if else if [தொகு]

string selection;
selection = "ta";
 
if (selection=="hi")
  cout<< "You have selected the Tamil Wikipedia"; 
else if (selection=="ta")
  cout<< "You have selected the Tamil Wikibooks"; 
else
  cout<< "You have selected the Tamil Wikisource";
You have selected the Tamil Wikipedia


தெரிவு/switch [தொகு]

சி++ பி.எச்.பி போன்ற இதர மொழிகள் போல் அல்லாமல் சொற்தொடர்களை தெரிவில் பயன்படுத்த முடியாது.

int selection;
selection = 2;
switch (selection){
  case 1:
        cout<< "You have selected Tamil Wikipedia";
        break;
  case 2:
    cout<< "You have selected Tamil Wikibooks";
    break;
  default:
    cout<< "You have selected Tamil Wikisource";
    break;
    }
You have selected Tamil Wikibooks


சுற்று [தொகு]

while சுற்று [தொகு]

int i=1;
while(i<=5)
  {
  cout << "The number is "<< i <<"\n" ;
  i++;
  }
The number is 1
The number is 2
The number is 3
The number is 4
The number is 5


do while சுற்று [தொகு]

int i=1;
do {
        cout << "The number is " << i << "\n";
        i++;
    } while (i <= 5);
The number is 1
The number is 2
The number is 3
The number is 4
The number is 5


do while சுற்று [தொகு]

int i=1;
 
for (i=1; i<=5; i++)
{
  cout << "Iteration:"<<i<<" Hello World!\n";
}
Iteration:1 Hello World!
Iteration:2 Hello World!
Iteration:3 Hello World!
Iteration:4 Hello World!
Iteration:5 Hello World!


செயலி [தொகு]

pass by value [தொகு]

int main (){
  int add (int a, int b);
  int ans;
  ans = add(4, 2);
  cout << "Ths sum is " << ans << "\n";
  return 0;
  }
 
int add (int a, int b){
        int ans;
        ans = a + b;
        return ans;
        }
The Sum is 6


pass by references [தொகு]

int main (){
  void passbyref (int& a, int& b);
  int a=1, b=3;
  passbyref (a, b);
  cout << "a=" << a << ", b=" << b << "\n";
  return 0;
  }
 
void passbyref (int& a, int& b){
  a = a + 10;
  b= b + 10;
  }
a=11, b=13;


பொருள் நோக்கு நிரலாக்கம் [தொகு]

class Calculator {
    int x, y;
    public:
        void set_values (int,int);
        int add () {
                        int ans;
                        ans = x + y;
                        return ans;
                        }
        };
 
void Calculator::set_values (int a, int b) {
        x = a;
        y = b;
        }
 
int main () {
        Calculator c1;
        c1.set_values (5, 3);
        cout << "The sum is: " << c1.add() << endl;
        return 0;
        }
The sum is: 8


இவற்றையும் பாக்க [தொகு]

வெளி இணைப்புகள் [தொகு]

"http://ta.wikipedia.org/w/index.php?title=சி%2B%2B&oldid=1396777" இருந்து மீள்விக்கப்பட்டது