© Slobodan Dmitrović 2020
S. DmitrovićModern C++ for Absolute Beginnershttps://doi.org/10.1007/978-1-4842-6047-0_24

24. Exercises

Slobodan Dmitrović1 
(1)
Belgrade, Serbia
 

24.1 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;
}

24.2 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;
}

24.3 Class with Member Function

Write a program that defines a class called MyClass with one member function called printmessage(). Define the printmessage() ...

Get Modern C++ for Absolute Beginners: A Friendly Introduction to C++ Programming Language and C++11 to C++20 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.