The World’s Largest Online Community for Developers

'; class - Trouble trying to use header C++ - LavOzs.Com

I'm new to C++, and I'm trying to learn how to call a class from an external header .h file. I simply put the testando.cpp, teste.h, and teste.cpp in the same directory. That was the problem that appeared when I tried to compile the testando.cpp:

    /tmp/ccpF455q.o: In function `main'
testando.cpp:(.text+0x24): undefined reference to `teste::teste(int)'
testando.cpp:(.text+0x30): undefined reference to `teste::get()'
collect2: error: ld returned 1 exit status:

The code:

#ifndef TESTE_H
#define TESTE_H

class teste
    int x;
    teste(int p);
    int get();



#include "teste.h"

teste::teste(int p)

int teste::get()
    return x;

using namespace std;
#include "teste.h"

int main()
    teste k(17);
    cout << k.get() << endl;

Do I need to compile the headers file, or do something else I didn't realize?

What are the differences between a pointer variable and a reference variable in C++?
How can I profile C++ code running on Linux?
The Definitive C++ Book Guide and List
Why can templates only be implemented in the header file?
What is the effect of extern “C” in C++?
What is the “-->” operator in C++?
How to fix “Headers already sent” error in PHP
Why is reading lines from stdin much slower in C++ than Python?
Error trying to use pthread on Ubuntu
In function undefined reference c++