Skip to content
Snippets Groups Projects
Commit 62ba0490 authored by Caleb Horton's avatar Caleb Horton :floppy_disk:
Browse files

Moved Node class outside of namespace with same issues

parent 41e8efe5
Branches project2
No related merge requests found
#include <iostream>
#include "myList.hpp"
//#include "myList.hpp"
#include "singleLinkNode.hpp"
#include "testUtils.hpp"
using namespace std;
using namespace Project2;
//using namespace Project2;
// Didn't know about this being an issue until now: https://stackoverflow.com/a/8752879
template class Node<int>;
int main(int argc, char** argv) {
//Node<int> origNode(100, (Node<int>*) NULL);
Node<int> origNode(100, (Node<int>*) NULL);
Node<int> origNode(100);
cout << "Hello, world!" << endl;
//cout << "Node value: " << origNode.value << endl;
}
// Didn't know about this being an issue until now: https://stackoverflow.com/a/8752879
template class Node<int>;
\ No newline at end of file
}
\ No newline at end of file
......@@ -2,14 +2,19 @@
#include "singleLinkNode.hpp"
template<typename T>
Node<T>::Node(T value, Node<T>* next) {
this->value = value;
this->next = next;
};
template<typename T>
Node<T>::Node(T value) {
this->value = value;
this->next = NULL;
};
/*
namespace Project2 {
template<typename T>
Node<T>::Node(T value, Node<T>* next) {
this->value = value;
this->next = next;
};
template<typename T>
Node<T>::Node(T value) : Node(value, NULL) {};
//std::ostream& operator<<(std::ostream& lhs, Project2::Node& rhs) {
// lhs << rhs.value;
......@@ -20,4 +25,5 @@ namespace Project2 {
// lhs << rhs.value;
// return lhs;
//};
}
\ No newline at end of file
}
*/
\ No newline at end of file
......@@ -3,50 +3,54 @@
#ifndef SINGLELINKNODE_HPP
#define SINGLELINKNODE_HPP 1
namespace Project2 {
template<typename T>
struct Node {
/**
* @brief Data held by the node with the type defined by the template
*/
T value;
/**
* @brief Pointer to the next node in the list chain
*/
Node<T>* next;
template<typename T>
class Node {
public:
/**
* @brief Data held by the node with the type defined by the template
*/
T value;
/**
* @brief Pointer to the next node in the list chain
*/
Node<T>* next;
/**
* @brief Create a new Node which points to another node
*
* @param value Value of the node
* @param next Pointer to the next node in a list
*/
Node(T value, Node<T>* next);
/**
* @brief Create a new Node with no default next value
*
* @param value Value of the node
*/
Node(T value);
};
/**
* @brief Create a new Node which points to another node
*
* @param value Value of the node
* @param next Pointer to the next node in a list
*/
Node(T value, Node<T>* next);
/**
* @brief Create a new Node with no default next value
*
* @param value Value of the node
*/
Node(T value);
};
/*
namespace Project2 {
/ * *
* @brief Inserts content of the node into a output stream
*
* @param lhs Stream to insert into
* @param rhs Node to get data from
* @return Original output stream for chaining
*/
* /
//std::ostream& operator<<(std::ostream& lhs, Project2::Node& rhs);
///**
// / * *
// * @brief Inserts content of the node into a string
// *
// * @tparam T Node value's type
// * @param lhs String to insert into
// * @param rhs Node to get data from
// * @return Original string for chaining
// */
// * /
//template<typename T>
//std::string& operator<<(std::string& lhs, Project2::Node<T>& rhs);
}
*/
#endif // SINGLELINKNODE_HPP
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment