Write the general form of class declaration in c++
Answers
Answered by
20
A class is defined in C++ using keyword class followed by the name of class. The body of class is defined inside the curly brackets and terminated by a semicolon at the end. Declaring Objects: When a class is defined, only the specification for the object is defined; no memory or storage is allocated.
Answered by
10
General form of class c++ is given below
Explanation:
- Class is the collection of variable and function basically the class concept is used for the object oriented programming.To accessing the properties of class we used the object .
- To declared any class following general syntax is used
class class-name
{
modifier:
variable and function
};
Void main() // main function
{
class-name object-name; // creating object
}
- For example:
class test // class{
public:
void fun1() // function
{
cout<<"hii";
}
};
void main()
{
test on; // creating object
on.fun1();// calling function
]
Output:
hii
Learn More :
- https://brainly.in/question/13172691
Similar questions