Somehting about how I initialize my private class memebers. The warning messages do not makes sense…I tried to see if they were concatenated..but they do’t appear to be..this is what Eclipse is saying. Sorry I can’t format it much better.
Here are the compiler message:
Description Resource Path Location Type
'sl_list<int>::node_1* sl_list<int>::head' test_a line 13 C/C++ Problem
when initialized here test_a line 18 C/C++ Problem
'sl_list<int>::count' will be initialized test_a line 14 C/C++ Problem
Relevant Code – call to linked_list
#include "c_include_list.cpp"
#include "c_linked_list.cpp"
using namespace std;
int main() {
cout << "sl_list" << endl;
sl_list<int> sl_list_object;
}
Relevant Code – linked_list implmentation
template <class T1> class sl_list
{
private:
class node_1
{
public:
T1 data;
node_1 *next;
node_1(T1 data, node_1 *next = NULL) : data(data), next(next) {}
};
node_1 *head; // line 13
int count; // line 14
public:
sl_list() : count(0), head(NULL){} // line 18
The answer is pretty simple: Initialize members in the order of declaration.
By default, this is only a warning, so Eclipse probably gave the -Wall and -Werror flags to the compiler.