I'm sure this is a common question, and I've been looking through similar questions; but i'm unable to get this resolved
C++11, CLion IDE
Error as follows:
undefined reference to `aBag::aBag()'
main.cpp is simple and has no logic as of yet
#include <iostream>
#include "aBag.h"
using namespace std;
int main() {
aBag setA;
return 0;
}
the following is header aBag.h, which i'm unable to edit
#ifndef BAG_
#define BAG_
#include <vector>
typedef int ItemType;
class aBag
{
private:
static const int DEFAULT_BAG_SIZE = 100;
ItemType items[DEFAULT_BAG_SIZE]; // array of bag items
int itemCount; // current count of bag items
int maxItems; // max capacity of the bag
// Returns either the index of the element in the array items that
// contains the given target or -1, if the array does not contain
// the target.
int getIndexOf(const ItemType& target) const;
public:
aBag();
int getCurrentSize() const;
bool isEmpty() const;
bool add(const ItemType& newEntry);
bool remove(const ItemType& anEntry);
void clear();
bool contains(const ItemType& anEntry) const;
int getFrequencyOf(const ItemType& anEntry) const;
}; // end Bag
#endif
constructor for aBag
#include "aBag.h"
aBag::aBag() : itemCount(0), maxItems(DEFAULT_BAG_SIZE)
{
}
cmakefile.txt
cmake_minimum_required(VERSION 3.12)
project(project2)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp aBag.cpp)
add_executable(project2 main.cpp)
output for make V=1
$make V=1
g++ -c -g -std=c++11 main.cpp
g++ -c -g -std=c++11 aBag.cpp
g++ -o project2 main.o aBag.o
is it syntax somewhere? do i need to be adding aBag.cpp or .h as a source file or target somewhere? something else entirely?
send help