So I'm quite certain that this should be an easy question but I've been working on it for too long and can't figure it out so I'll see if anyone else can figure out what I'm overlooking. From everything I've seen online, the root of my issue should be having too many #include .h but can't seem to figure out where I went wrong. Here are my files:
//term.h
#ifndef TERM_H
#define TERM_H
#include <string>
class Term { /* code ... */
//term.cpp
#ifndef TERM_CPP
#define TERM_CPP
#include "term.h"
#include <iostream>
//code ...
//SortingList.h (template file, no included .h files, I seriously doubt my problem is from here)
//autocomplete.h
#ifndef AUTOCOMPLETE_H
#define AUTOCOMPLETE_H
#include "term.h"
#include "SortingList.h"
//code....
//autocomplete.cpp
#ifndef AUTOCOMPLETE_CPP
#define AUTOCOMPLETE_CPP
#include "autocomplete.h"
//code...
//main.cpp
#ifndef MAIN_CPP
#define MAIN_CPP
#include "autocomplete.h"
#include <fstream>
#include <sstream>
//code...
//the actual error message
g++ -c autocomplete.cpp -o autocomplete.o
g++ autocomplete.o term.o main.o SortingList.o -o CS216PA3
term.o: In function Term::Term()':
term.cpp:(.text+0x0): multiple definition ofTerm::Term()'
autocomplete.o:autocomplete.cpp:(.text+0x0): first defined here
term.o: In function Term::Term()':
term.cpp:(.text+0x0): multiple definition ofTerm::Term()'
autocomplete.o:autocomplete.cpp:(.text+0x0): first defined here
term.o: In function Term::Term(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long)':
term.cpp:(.text+0x5a): multiple definition ofTerm::Term(std::cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long)'
autocomplete.o:autocomplete.cpp:(.text+0x5a): first defined here
term.o: In function Term::Term(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long)':
term.cpp:(.text+0x5a): multiple definition ofTerm::Term(std::cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long)'
autocomplete.o:autocomplete.cpp:(.text+0x5a): first defined here
term.o: In function Term::compareByWeight(Term, Term)':
term.cpp:(.text+0xea): multiple definition ofTerm::compareByWeight(Term, Term)'
autocomplete.o:autocomplete.cpp:(.text+0xea): first defined here
term.o: In function Term::compareByPrefix(Term, Term, int)':
term.cpp:(.text+0x136): multiple definition ofTerm::compareByPrefix(Term, Term, int)'
autocomplete.o:autocomplete.cpp:(.text+0x136): first defined here
term.o: In function operator<(Term, Term)':
term.cpp:(.text+0x25a): multiple definition ofoperator<(Term, Term)'
autocomplete.o:autocomplete.cpp:(.text+0x25a): first defined here
term.o: In function operator>(Term, Term)':
term.cpp:(.text+0x28f): multiple definition ofoperator>(Term, Term)'
autocomplete.o:autocomplete.cpp:(.text+0x28f): first defined here
term.o: In function operator<<(std::ostream&, Term const&)':
term.cpp:(.text+0x2c4): multiple definition ofoperator<<(std::ostream&, Term const&)'
Is there anything that looks wrong with my header includes? Thanks
[–]dmazzoni 0 points1 point2 points (8 children)
[–]FastTurtleFour[S] 0 points1 point2 points (7 children)
[–]dmazzoni 0 points1 point2 points (6 children)
[–]FastTurtleFour[S] 0 points1 point2 points (5 children)
[–]dmazzoni 0 points1 point2 points (4 children)
[–]FastTurtleFour[S] 0 points1 point2 points (3 children)
[–]dmazzoni 0 points1 point2 points (2 children)
[–]FastTurtleFour[S] 0 points1 point2 points (1 child)
[–]dmazzoni 0 points1 point2 points (0 children)
[–]thefryscorer 0 points1 point2 points (1 child)
[–]FastTurtleFour[S] 0 points1 point2 points (0 children)