Question

In: Computer Science

Using*************** C++ **************** explain what Objects and Classes are. Please describe in detail.

Using*************** C++ **************** explain what Objects and Classes are. Please describe in detail.

Solutions

Expert Solution

CLASS :

C++ is an object-oriented programming language.

A class is a user-defined data type, which contains its own data members and member functions(Methods) , which can only be accessed and operated by creating an instance of that class.

Hence, a class is said as a blueprint for the object.

CREATION OF A CLASS :

class ClassName

{

public : // access specifier

int name ; // attrbutes

void fun(); //member functions

} ;

EXPLANATION OF ABOVE CLASS ;

To use classes we write the keyword class followed by the name of class. The body of class is defined inside the curly brackets where we can include the access specifier and the attributes and the member functions ,and the class is terminated by a semicolon at the end.

OBJECT :

When a class is defined, only the specification for the object is defined; and no memory is allocated for defining that class.

But , to use the data and access member functions present in the class, we need to create objects.

Hence, Object is created by following the below statement :

ClassName ObjectName;

EXAMPLE OF OBJECT :

For example , in above , we created a class named "ClassName" , and if to use the attributes and methods of that class, we need to create the object by writing the below statement :

ClassName ob1;

where,

"ClassName" is the name of the class and ob1 is the name of the object for class "ClassName".

And to use the attributes / methods of class "ClassName" we write :

ob1.name ; //to access name of class "ClassName"

ob1.fun(); //to access method of the class "ClassName"


Related Solutions

A. What are Objects? B. How do Objects differ from Classes? C. Where are Objects stored...
A. What are Objects? B. How do Objects differ from Classes? C. Where are Objects stored in Memory? D. Why do you not need to declare when you are finished using an Object in Java? E. Can you edits the contents of a String? View keyboard shortcuts EditViewInsertFormatToolsTable 12pt Paragraph
Homework 3 – Programming with C++ What This Assignment Is About: • Classes and Objects •...
Homework 3 – Programming with C++ What This Assignment Is About: • Classes and Objects • Methods • Arrays of Primitive Values • Arrays of Objects • Recursion • for and if Statements • Insertion Sort 2. Use the following Guidelines • Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc). • User upper case for constants. Use title case (first letter is upper case) for classes. Use lower case with uppercase word separators for...
Explain what classes and objects are in object - oriented programming. Give an example of each...
Explain what classes and objects are in object - oriented programming. Give an example of each and explain how they work together in a computer program.
Describe what production-related risks are? please explain in detail and please no handwriting. Thanks
Describe what production-related risks are? please explain in detail and please no handwriting. Thanks
Write a C# code that creates objects and classes with their member functions for KrisFlyer, a...
Write a C# code that creates objects and classes with their member functions for KrisFlyer, a Singapore Airlines Loyalty program. You are asked to write an inheritance hierarchy discount system that benefits KrisFlyer members program to calculate their profit. A brief about KrisFlyer is that it is useful for those who fly on Singapore Airlines (its partners like Virgin Australia and Air New Zealand) frequently. KrisFlyer miles can be earned through credit cards, flying and bonus miles promotions. The miles...
1. Cap rates vary considerably across the different property types/classes. Please explain in detail what is...
1. Cap rates vary considerably across the different property types/classes. Please explain in detail what is responsible for these differences. (i.e., what is driving the differences in cap rates across the different property types)
Create a C++ code for the mastermind game using classes(private classes and public classes). Using this...
Create a C++ code for the mastermind game using classes(private classes and public classes). Using this uml as a reference.
(Java) Please describe how API's can be created using abstract classes, interfaces and regular classes.
(Java) Please describe how API's can be created using abstract classes, interfaces and regular classes.
please explain in detail What is the PCAOB? Please explain what is the law, a describiton...
please explain in detail What is the PCAOB? Please explain what is the law, a describiton of the law.
How algorithms address object-oriented classes and objects. What is the File object? How are File objects...
How algorithms address object-oriented classes and objects. What is the File object? How are File objects used in algorithms? 175 words minumum please :)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT