Declaring a class in C++

Asked By 55 points N/A Posted on -
qa-featured

Hi! In object oriented programming in c++, how do we declare a class? Please include the following things in the declaration of class and also mention their definitions at the end. The access specifiers, the constructor, the destructor. Why do we use a class? What are the advantages of classes in programming?

SHARE
Answered By 0 points N/A #182758

Declaring a class in C++

qa-featured
Hi Pamela,
 
Below is an example for declaration of a class and the description is given below.
 
class class_name {
  access_spec_1:
    member1;
  access_spec_2:
    member2;
  …
} obj_names;
 
Class_name refers to a valid identifier for this particular class. obj_names is an optional list of object names of this class. The body of a class declaration can either be data or functional declarations. An access specifier can either be private, public or protected. These are responsible for modifying the access rights for their members. All members of a class declared with keyword class have private access by default. Classes allow programs to be written using object oriented paradigms.
 
Regards,
Anyet

Related Questions