COMPUTER SCIENCE WITH C++

12 downloads 3628 Views 614KB Size Report
www.cppforschool.com. COMPUTER SCIENCE. WITH C++. FOR CBSE CLASS 12. Revision Notes. Part -I. [Structure, Class and Object, Constructor and.
www.cppforschool.com

COMPUTER SCIENCE WITH C++ FOR CBSE CLASS 12

Revision Notes Part -I

[Structure, Class and Object, Constructor and Destructor, Inheritance, File Handling, Pointer, Array, Data Structure and class 11th revision tour] (Question 1,2,3,4 of Board Exam Paper)

CONTENTS Structure ................................................................................................................ 3 Typedef ................................................................................................................. 5 Enumerated Data Type ............................................................................................ 6 #Define Preprocessor Directive ................................................................................. 6 Macros ................................................................................................................... 6 Assignment ............................................................................................................ 6 Oop Concepts ......................................................................................................... 8 Classes & Objects ................................................................................................... 9 Assignment .......................................................................................................... 10 Constructor And Destructor.................................................................................. 11 Assignment .......................................................................................................... 12 Inheritance .......................................................................................................... 13 Assignment .......................................................................................................... 14 Data File Handling In C++ .................................................................................... 17 Basic Operation On Text File ................................................................................... 19 Assignment .......................................................................................................... 22 Basic Operation On Binary File In C++..................................................................... 23 Assignment .......................................................................................................... 24 Array .................................................................................................................... 26 Basic Operation On One Dimensional Array .............................................................. 27 Two Dimensional Arrays ......................................................................................... 30 Assignment .......................................................................................................... 34 Pointer ................................................................................................................. 35 Assignment .......................................................................................................... 40 Data Structure...................................................................................................... 41 Static Stack .......................................................................................................... 41 Static Circular Queue ............................................................................................. 42 Dynamic Stack...................................................................................................... 44 Dynamic Queue .................................................................................................... 46 Assignment .......................................................................................................... 48 C++ Basic Concepts (Revision Tour Of Class 11).................................................. 48 Library Function ................................................................................................... 52 Assignment .......................................................................................................... 54 Solution Of Assignments ...................................................................................... 56

www.cppforschool.com

Page 2

STRUCTURE A structure is a collection of variable which can be same or different types. You can refer to a structure as a single variable, and to its parts as members of that variable by using the dot (.) operator. The power of structures lies in the fact that once defined, the structure name becomes a user-defined data type and may be used the same way as other built-in data types, such as int, double, char. struct STUDENT { int rollno, age; char name[80]; float marks; }; int main() { STUDENT s1, s3; // declare two variables of the new type cin >> s1.rollno >> s1.age >> s1.name >> s1.marks; cout