Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 839453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:27:57+00:00 2026-05-15T05:27:57+00:00

So I’m trying to learn C++ and I’ve gotten as far as using header

  • 0

So I’m trying to learn C++ and I’ve gotten as far as using header files. They really make no sense to me. I’ve tried many combinations of this but nothing so far has worked:

Main.cpp:

#include "test.h"

int main() {
    testClass Player1;
    return 0;
}

test.h:

#ifndef TEST_H_INCLUDED
#define TEST_H_INCLUDED
class testClass {
    private:
        int health;
    public:
        testClass();
        ~testClass();
        int getHealth();
        void setHealth(int inH);
};
#endif // TEST_H_INCLUDED

test.cpp:

#include "test.h"

testClass::testClass() { health = 100; }
testClass::~testClass() {}

int testClass::getHealth() { return(health); }
void testClass::setHealth(int inH) { health = inH; }

What I’m trying to do is pretty simple, but the way the header files work just makes no sense to me at all. Code blocks returns the following on build:

obj\Debug\main.o(.text+0x131)||In function main':|
*voip*\test\main.cpp
|6|undefined reference to
testClass::testClass()’|
obj\Debug\main.o(.text+0x13c):voip\test\main.cpp|7|undefined reference to `testClass::~testClass()’|
||=== Build finished: 2 errors, 0 warnings ===|

I’d appreciate any help. Or if you have a decent tutorial for it, that would be fine too (most of the tutorials I’ve googled haven’t helped)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T05:27:57+00:00Added an answer on May 15, 2026 at 5:27 am

    Code::Blocks doesn’t know that it has to compile test.cpp and produce an object file test.o (so that the latter may be linked together with main.o to produce the executable). You have to add test.cpp to your project.

    In Code::Blocks, go to Project>Add File in the menu and select your test.cpp file. Make sure that both Release and Debug checkboxes are checked.

    Then Build->Rebuild.

    EDIT:

    Here’s a tip to help you see what the IDE is doing under the hood when compiling. Go to Settings -> Compiler and Debugger -> Global Compiler Settings -> Other settings and select Full command line in the Compiler logging drop box. Now, whenever you build, the gcc compiler commands will be logged in the Build Log. Whenever someone on StackOverflow asks you for the gcc command line you used, you can copy and paste what’s in the Build Log.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 409k
  • Answers 409k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'd use the .toggle() method to make the toggle work,… May 15, 2026 at 7:15 am
  • Editorial Team
    Editorial Team added an answer Looks like the inspiration was Haskell's type classes. At least… May 15, 2026 at 7:15 am
  • Editorial Team
    Editorial Team added an answer When Enqueue fails, you're still incrementing p.tail, so next time… May 15, 2026 at 7:15 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.