Question 2 (15 marks) 300-500 words per discussion and avoid plagiarism. Discuss the following.
a. b. c. d. e.
Pointers Arrays Structures
Classes functions
A pointer is a variable that stores a memory address as its value.
A pointer variable points to a data type (like int or string) of the same type, and is created with the operator.
An array in C/C++ or be it in any programming language is a collection of similar data items stored at contiguous memory locations and elements can be accessed randomly using indices of an array. They can be used to store collection of primitive data types such as int, float, double, char, etc of any particular type. To add to it, an array in C/C++ can store derived data types such as the structures, pointers etc.
A structure is a user-defined data type in C/C++. A structure creates a data type that can be used to group items of possibly different types into a single type.
A class in C++ is the building block that leads to Object-Oriented programming. It is a user-defined data type, which holds its own data members and member functions, which can be accessed and used by creating an instance of that class. A C++ class is like a blueprint for an object.
A function is a group of statements that together perform a task. Every C++ program has at least one function, which is main(), and all the most trivial programs can define additional functions.
Comments
Leave a comment