Missed the link somewhere...

Please help me with this(soo tired).
No compile errors but the linker tells me(using g++):
Z:\home\aceix\Desktop\Sublime Text 2\C++ Codes\test_menu_wrapper.o:test_menu_wrapper.cpp|| undefined reference to `MenuWrapper::MenuWrapper(std::string const&, std::string const&, std::vector<std::string, std::allocator<std::string> > const&)'|
Z:\home\aceix\Desktop\Sublime Text 2\C++ Codes\test_menu_wrapper.o:test_menu_wrapper.cpp|| undefined reference to `MenuWrapper::updateSelectionPos(Directions)'|
Z:\home\aceix\Desktop\Sublime Text 2\C++ Codes\test_menu_wrapper.o:test_menu_wrapper.cpp|| undefined reference to `MenuWrapper::displayMenu()'|
Z:\home\aceix\Desktop\Sublime Text 2\C++ Codes\test_menu_wrapper.o:test_menu_wrapper.cpp|| undefined reference to `MenuWrapper::~MenuWrapper()'|
Z:\home\aceix\Desktop\Sublime Text 2\C++ Codes\test_menu_wrapper.o:test_menu_wrapper.cpp|| undefined reference to `MenuWrapper::~MenuWrapper()'|
||=== Build failed: 5 error(s), 0 warning(s) (0 minute(s), 5 second(s)) ===|


The code maybe messy as this is a quick brush through(no planning).

test_menu_wrapper.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <vector>
#include <chrono>
#include <thread>

#include "MenuWrapper.h"

using namespace std;

int main() {
	vector<string> menu{"Play","Help","About","Exit"};
	MenuWrapper mainMenu("Welcome To My Game!","Type the number:",menu);
	Directions arrowKeyDirection = Directions::DOWN;

	for(int i=0; i<10; i++) {
		mainMenu.updateSelectionPos(arrowKeyDirection);
		mainMenu.displayMenu();
		this_thread::sleep_for(chrono::seconds(1));
	}

	return 0;
}


MenuWrapper.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
27
28
29
30
31
32
33
34
//creating interactive console menu
#pragma once

#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <cstdlib>

enum class Directions {
	UP, DOWN
};

class MenuWrapper {
private:
	std::vector<std::string> menuItems;
	int currentSelectionPos;
	std::string welcome;
	std::string instruction;
	int maxNumOfItems;
protected:
public:
	MenuWrapper();
	MenuWrapper(std::string const&, std::string const&, std::vector<std::string> const&);

	inline void setWelcome(std::string const&);
	inline void setInstruction(std::string const&);
	inline void setMenuItems(std::vector<std::string> const&);
	void updateSelectionPos(Directions);
	inline int getSelectionPos();
	void displayMenu();

	~MenuWrapper();
};


MenuWrapper.cpp
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "MenuWrapper.h"

MenuWrapper::MenuWrapper() {
	currentSelectionPos = maxNumOfItems = 0;
	welcome = "";
}

MenuWrapper::MenuWrapper(std::string const& intro, std::string const& ins, std::vector<std::string> const& initVal) {
	currentSelectionPos = maxNumOfItems = 0;
	welcome = instruction = "";
	welcome = intro;
	instruction = ins;
	if (initVal.size()>0) {
		menuItems=initVal;
		maxNumOfItems = (menuItems.size() - 1);
	}
}

int MenuWrapper::getSelectionPos() {
	return currentSelectionPos;
}

void MenuWrapper::updateSelectionPos(Directions dir) {
	switch(dir) {
		case Directions::UP:
			if(currentSelectionPos == 0) {
				currentSelectionPos = maxNumOfItems;
			}
			else {
				currentSelectionPos--;
			}
			break;
		case Directions::DOWN:
			if(currentSelectionPos == maxNumOfItems) {
				currentSelectionPos = 0;
			}
			else {
				currentSelectionPos++;
			}
			break;
	}
}

void MenuWrapper::setMenuItems(std::vector<std::string> const& items) {
	if (items.size()>0) {
		menuItems=items;
		maxNumOfItems = (menuItems.size() - 1);
	}
}

void MenuWrapper::setInstruction(std::string const& ins) {
	instruction = ins;
}

void MenuWrapper::displayMenu() {
	std::stringstream outStream;

	outStream<<welcome<<"\n\n"<<std::flush;
	outStream<<instruction<<"\n"<<std::flush;

	for(int i=0; i < menuItems.size(); i++) {
		if(i != currentSelectionPos)
			outStream<<"\t"<<(i + 1)<<". "<<menuItems[i]<<std::endl;
		else 
			outStream<<"\t\t-> "<<(i + 1)<<". "<<menuItems[i]<<std::endl;
	}

	outStream<<"\nSelection: ";

	system("CLS");

	std::cout<<outStream.str();
}

MenuWrapper::~MenuWrapper() {}


Thanks for the help,
Aceix.
Topic archived. No new replies allowed.