GNU GCC: "syntax error"

Hello, I am working on learning C++ so please forgive me if this is a silly error as I know very little currently. I am using GNU GCC on Linux and Code::Blocks. When I try to compile this file, I get the following error:

1
2
3
||=== Build: Debug in Learning2 (compiler: GNU GCC Compiler) ===|
/usr/bin/ld:capybara.h.gch|1|syntax error|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|


I have no idea what this error means (as far as I know, the syntax is correct), and it does not even appear to be in the code file but rather a .gch file which I would assume is an intermittent file that GNU GCC uses -- so I wouldn’t be causing any errors in it. This error is also very non-specific so I'm not sure where I need to look in my code to fix it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//capybara.h
#ifndef CAPYBARA_H
#define CAPYBARA_H
#include <string>

class Capybara
{
    public:
        Capybara();
        Capybara(std::string);
        void setSnarlVar(std::string x);
        std::string getSnarlVar();
        void snarl();
    protected:
    private:
        std::string snarlVar;
};

#endif // CAPYBARA_H


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//capybara.cpp
#include "capybara.h"
#include <iostream>
#include <string>
using namespace std;

Capybara::Capybara(){
    setSnarlVar("SNARL!");
}

Capybara::Capybara(string x){
    Capybara::setSnarlVar(x);
}

void Capybara::setSnarlVar(string x){
    this->snarlVar = x;
}

void Capybara::snarl(){
    cout << Capybara::getSnarlVar() << endl;
}

string Capybara::getSnarlVar(){
    return snarlVar;
}


Thanks for reading (and hopefully answering)!
Topic archived. No new replies allowed.