0

There is photo of files included in this program

Some time ago I started learning object programming in C++ in VSCode. I decided to create quiz using three files - main.cpp, pytanie.h, pytanie.cpp. I wrote all the code which was necessary. My problem is that when I want to start debugging it shows me communique like that:

The statement which VSCode shows me

For addition maybe it will help, I'm gonna paste code form main.cpp:

#include <iostream>
#include "pytanie.h"

using namespace std;

int main()
{
Pytanie p1;
p1.nr_pytania = 1;
p1.wczytaj();
p1.zadaj();
p1.sprawdz();

cout << "KONIEC QUIZU! PUNKTY = " << p1.punkt;

return 0;
}

There's file pytanie.h

Krecikkko
  • 1
  • 1
  • 2
    instead of `g++ main.cpp` you need to compile all the .cpp files in your project – M.M Jun 23 '20 at 20:38
  • This is in the documentation for vscode here: [https://code.visualstudio.com/docs/cpp/config-mingw#_modifying-tasksjson](https://code.visualstudio.com/docs/cpp/config-mingw#_modifying-tasksjson) – drescherjm Jun 23 '20 at 20:49
  • 1
    VSCode can be a pain to beat into submission. This may change in a few years and a few more iterations of VSCode, but for now if you're learning C++ you probably don't also want to be learning how to wrangle your build tools. See if you can use a community edition of Visual Studio or something with simpler C++ integration. – user4581301 Jun 23 '20 at 20:50

1 Answers1

0

Instead of running g++ main.cpp on PS, you should run : g++ main.cpp pytanie.cpp.

Check out this thread for more information.

One thing I would like to add is don’t write namespace usings in a header file. Check this thread.

Also I would recommend you to follow this tutorial to setup tasks.json in your workspace. It can save your typing! :)

brc-dd
  • 10,788
  • 3
  • 47
  • 67