Professional Documents
Culture Documents
WHAT IS C++..
C++ is an object-oriented programming language. It was developed by bjarne stroustrup at AT & T bell lab in murray hill,new jersey,usa. Stroustrup an admirer of c wanted to combine the best of both the languages and create a more powerful languages that could support object-oriented programming feature and still retain the power and elegance of c.The resut was c++.
3. Derived datatype.
User-define datatype
Structure and class:
we have studied some userdefine data types like struct & union in c. it is legal in c++ but some more features are added into it to make suitable for oop.class specification has two parts: [i]class declaration. [ii]class function defination. Class declaration describe the type & scope of member.function defination describe how the is class function is implemented.
In order to define a new simple data type, called enumeration type, we need: A name for the data type. A set of values for the data type. A set of operations on the values.
The values that we specify for the data type must be legal identifiers The syntax for declaring an enumeration type is:
enum typeName{value1, value2, ...};
The identifiers between { } are called enumerators The order of the declaration is significant red < orange < yellow
10
Given:
enum daysOfWeek { Sun, Mon, Tue,Wed, Thu, Fri, Sat }
Then we declare:
daysOfWeek Today, payDay, dayOff;
11
Build-in datatype
Void:There are basically three
advantages of keyword void: [i] To specify return type of function when it is not returning any value. [ii] To indicate an empty argument list to a function. Example: void display (void). [iii] In the declaration of generic pointer. Void *gp; gp becomes a generic pointer.
12
13
ARRAYS
DEFINITION: The C language provides a capability that enables the user to design a set of similar data types called ARRAYS. Eg. # include<stdio.h> void main() { int x; x=5; X=10; Printf(\nx=%d,x); }
14
15
FUNCTIONS
DEFINITION:
A function is a self-contained block of statements that perform a coherent task of some kind.
16
Function Prototyping
Function prototyping is one of the major improvement added to c++ functions. The prototype describe the function interface to the compiler by giving details like the numbers & the type of arguments & the type of return values.
The function prototype is a declearation statement in calling programm a&is of the following form:
Eg.
1. float volume( int x, float y, float z); 2. float volume( int x, float y, z); 3. float volume( int , float , float);
17
18
In C++, the main() returns a value of type int to the operating system. C++, therefore, explicitly defines main() as matching one of the following prototypes. int main(); int main(int argc, char * argc[]); The function that have a return value should use the return statement for termination. The main() function in C++ is therefore, defined as follows: int main() { :::::::::::::::: return 0; }
19
20
THANK YOU