C++ libraries

Asked

Viewed 200 times

-1

my problem is this: my college activity is to create a program in which the user can move the cursor from the screen to where he wants, using coordinates, and also the user can change the color of the text and the background of the text. This program needs to be written in C++. I know you can use the "windows library. h" for this, but my teacher said that you can’t use any C library, it has to be C++, that is, you can’t use any library with ". h" and I will also not be able to use the "system(""color x)" command, using Windows cmd. I was wondering if you had your own C++ library for that, or any other method that you would advise. my system is Windows 10, and I am using VISUAL STUDIO 2017.

  • Maybe it’s helping you #include <QtGui>, read more here and here.

1 answer

1

The screen concept does not exist in C or C++. This abstraction is usually provided by the operating system or by third parties.

Realize that naming a header with .h does not make it C code. User headers in C++ are also usually named with .h and included with #include "meu_header.h".

To illustrate this concept, you can save your header without the .h and include it with #include "meu_header". If you want to go further and use < >, as in #include <meu_header>, Just copy the file to one of the standard header directories used by the compiler (in my Macos, for example /usr/local/include). None of this will make your code C or more++.

The header windows.h is an integral part of the Windows API (WinAPI). To WinAPI has several versions depending on the platform, for example Win16, Win32 and Win64. The Winapi aims to be used by codes typically in C language. Other Apis have been developed by encapsulating the WinAPI in order to facilitate its use, ex. MFC, ATL, WTL. For example, the MFC was developed with the concept of object orientation for typical use in C++. Ultimately, most frameworks for Windows will use the WinAPI, including .NET and Java. So if you’re going to use the Windows GUI features, your code will probably be depending on the WinAPI, even if not in an apparent way.

If the goal is to develop a GUI application using third-party libraries, there are options like Qt and wxWidgets.

Anyway, if you want to emulate a screen in text mode (style ncurses) using only C++ and STL, so I believe the way is to use special ASCII characters and then print the output text overlay.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.