C++ this pointer

In C++ programming language the this pointer is used to refer to the current object. The this pointer is not use to access static members of the class because the static members do not belong to a specific object.

#include <iostream>
#include <conio.h>
using namespace std;
class Triangle{
    //data members
         double a,b;
    Triangle(double a,double b){this->a=a;this->b=b;}
    //this->a refers to class data member a
    //a refers to a argument
    //this->b refers to class data member b
    //b refers to b argument

    //method members
         double getPerimeter();
         double getPerimeter(double a,double b);
         double getArea();
         double getArea(double a,double b);
double Triangle::getPerimeter(double a,double b){
       double c=sqrt(pow(a,2)+pow(b,2));
double Triangle::getArea(double a,double b){
double Triangle::getPerimeter(){
       double c=sqrt(pow(a,2)+pow(b,2));
double Triangle::getArea(){
int main(){
   Triangle tr(10,20);
   Triangle tr1;
   return 0;

Posted by: kello bashy | post date: 01-26-2013 | Subject: C++ Programming Language

This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.