answersLogoWhite

0

C is procedural programming language and does not have any object orientated paradigm.

But there is C++ programming language that is C Object-Orientated approach and one of the most popular programming language (rapidly going down).

C++ brought some features to C Programming languages. And one of them is support for classes with fours main OO (Object-Orientated) features: encapsulation, abstraction, inheritance and polymorphism.

Object is an instance of the class, which is created at run-time.

Class is like a template for Object. It tells what kind of data inside it should have and what kind of operations are possible with it (abstraction).

Here is example of the Class:

class Point {

public:

Point();

Point(int x, int y);

~Point();

void setPoint(int x, int y);

int getX();

int getY();

private:

int x;

int y;

};

Point::Point() : x(0), y(0) {

}

Point::Point(int x, int y) {

this->setPoint(x, y);

}

Point::~Point() { }

void Point::setPoint(int x, int y) {

this->x = x;

this->y = y;

}

int Point::getX() {

return this->x;

}

int Point::getY() {

return this->y;

}

Here is example of small program that creates two objects and manipulates them:

#include

using namespace std;

int main() {

Point *a = new Point(1, 2); // Object a

Point *b = new Point(3, 4); // Object b

cout << "a.X = " << a->getX() << "; a.Y = " << a->getY() << endl;

cout << "b.X = " << b->getX() << "; b.Y = " << b->getY() << endl;

delete a;

delete b;

return 0;

}

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

What are the reasons for rise of constructor concept in c?

Not sure what you mean by this. C is a not an object-oriented programming (OOP) language, and therefore has no constructor concept. You probably meant C++ but, even so, there is no "rise of constructor concept". Constructors are fundamental to OOP -- they allow you to initialise an object at the point of instantiation.


What is object in c?

C is not a object-oriented language, hence object does not exist in C


Is c an object oriented programing language?

C language is not a program, and it isn't an object-oriented language either.


Is c plus plus an object orinted language?

Yes, it is object-oriented, but it is not 100% object-oriented because it supports the concept of primitive variables (which it inherits from C) such as char, int and bool, as well as pointer variables. In a 100% object-oriented language, these primitives would be implemented as objects, as they are in C# and Java. C++ is best described as a hybrid of procedural, structured and object-oriented programming paradigms.


Why do you require a object in java but not in C?

Because Java is an object-oriented language and C is a procedural language.


Is c is complete object oriented programming language?

No. C is not object oriented. C++ is object oriented.


What is objective c?

C is not a object-oriented language, hence object does not exist in C


Is c plus plus an object oriented language or an object based language?

C++ is object-oriented. It is not object-based because, like C before it, C++ supports the principal of primitive data types, which are not object-based.


Is c object oriented or object based?

C is a procedural programming language.


Whether c language is object oriented or not?

C is not, C++ is.


What is the topNet class that everything is derived from in c?

C language: int (but C is NOT a .net language) C# language: object or System.Object


Who invented cpp?

Bjarne Stroustrup is the recognized inventor of the C++ object oriented programming language. C++ was an enhancement to the C language, which was not object oriented.