0

I have a problem in CodeBlocks when I create a new Class folder, some folders are missing. When I run the program it says:

1- undefined reference to `bruh::bruh(int, int)'|

2- undefined reference to `bruh::print()'|

and here's how the files look like:

The main.cpp file:

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

using namespace std;

int main()
{
    bruh object(1,2);
    object.print();
}

The Header file bruh. (it's supposed to be bruh.h, here's the problem):

#ifndef BRUH_H
#define BRUH_H

class bruh
{
    public:
        bruh(int a, int b);
        void print();
    private:
        int Regular();
        int Constant();
};

#endif // BRUH_H

In the source file bruh. (it's supposed to be bruh.cpp, here's another problem)

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

using namespace std;

bruh::bruh(int a, int b)
:Regular(a), Constant(b)
{
    //ctor
}

void bruh::print(){
    cout << "Regular" << Regular << endl:
    cout << "Constant" << Constant << endl;
}

When creating the Class I uncheck the "Has Destructor" option, and check the "Add paths to project" and "Header and implementation file should be in the same folder" options.

I realized that there's no .h and .cpp where there should be. Any solutions?

drescherjm
  • 10,365
  • 5
  • 44
  • 64
plotter
  • 9
  • 3
  • It looks like `bruh.cpp` is not part of your project. – drescherjm May 01 '21 at 11:22
  • ***I realized that there's no .h and .cpp where there should be. Any solutions?*** First figure out where your source files are. I expect they are somewhere in the project folder but not added to your project in your IDE. – drescherjm May 01 '21 at 11:23
  • @drescherjm, it was working no problem, suddenly this problem occurred. I hadn't changed anything though. – plotter May 01 '21 at 11:24
  • I still repeat my comment. Find your files and I am sure there is an option in one of the menus to add files to your project. I am not sure how the files got removed from your project. – drescherjm May 01 '21 at 11:47
  • Not to waste your time, it doesn't even create bin folder nor obj nor the source file of the class. And for the option that adds the files to my project, it's already checked. It's not with the specific project I'm working on, it's on every new project I create class in. – plotter May 02 '21 at 07:40

0 Answers0