You are on page 1of 3

what is the main difference between c and c++?

Answer The main Difference between C and # 8 C++ is C is Object Based

program.that means in C also we have Object based Applications like Structures and Unions. C++ is Object Oriented Language that means entire application will be depending on Objects only. Uses of Object oriented Program is Reusability,Increase the effiency of the program and it gives extra security like Private data is also be there in C++. C++ is the Advanced version of C. In otherwords we say c++ supports both Object based and Object oriented Applications In object oriented programming, the programmer can solve problems by breaking them down into real-life objects (it presented the programmer with an opportunity to mirror real life). What is an object? This topic is dealt with extensively in the chapter on Objects and Classes but a brief introduction is provided here. Consider the category of cars. All cars have some common features (for example all cars have four wheels, an engine, some body colour, seats etc.). Are all cars the same? Of course not. A Fiat and a Ford arent the same but they are called as cars in general. In this example cars will form a class and Ford (or Fiat) will be an object.

For those people who know C programming, it would be useful to know the differences between C and C++. Basically C++ includes everything present in C but the use of some C features is deprecated in C++. *C does not have classes and objects (C does not support OOP) *Structures in C cannot have functions. *C does not have namespaces (namespaces are used to avoid name collisions). *The I/O functions are entirely different in C and C++ (ex: printf( ), scanf( ) etc. are part of the C language). *You cannot overload a function in C (i.e. you cannot have 2 functions with the same name in C). *Better dynamic memory management operators are available in C++. *C does not have reference variables (in C++ reference variables are used in functions). *In C constants are defined as macros (in C++ we can make use of const to declare a constant). *Inline functions are not available in C.

tell about copy constructor Answer A copy constructor is a special # 1 constructor in the C++

programming language used to create a new object as a copy of an existing object. There are 3 important places where a copy constructor is called. When an object is created from another object of the same

type When an object is passed by value as a parameter to a function When an object is returned from a function

class B //With copy constructor { private: char *name; public: B() { name = new char[20]; } ~B() { delete name[]; } //Copy constructor B(const B &b) { name = new char[20]; strcpy(name, b.name); } };
what is meant by files? Answer a file is a collection of records # 1 and a record is a

collection of fields.by keeping ur data on file u can save permunently.that is a file is saved on disk memory

You might also like