© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
S. DmitrovićModern C++ for Absolute Beginnershttps://doi.org/10.1007/978-1-4842-9274-7_24

24. Exercises

Slobodan Dmitrović1  
(1)
Belgrade, Serbia
 

Class Instance

Write a program that defines an empty class called MyClass and makes an instance of MyClass in the main function.
class MyClass
{
};
int main()
{
    MyClass o;
}

Class with Data Members

Write a program that defines a class called MyClass with three data members of type char, int, and bool. Make an instance of that class inside the main function.
class MyClass
{
    char c;
    int x;
    bool b;
};
int main()
{
    MyClass o;
}

Class with Member Function

Write a program that defines a class called MyClass with one

Get Modern C++ for Absolute Beginners: A Friendly Introduction to the C++ Programming Language and C++11 to C++23 Standards now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.