Hello, I'm having some trouble getting a piece of code to work, I've simplified it down as much as I could... so here it is.
It is basically an organization issue because I want to add a few more functions to a class which are unrelated to previously existing functions within the class(e.g. I want to separate object management functions from file IO functions but still have them in the same class), so I made a master flex.cpp file where the class is defined with all of the prototypes...
typically I build the class with each function defined completely from within, no prototyping, but then as the class grows it begins to get messy, so here is the problem, how would I make a function (who returns a pointer to a structure within the class) a member of a class? For instance:
Code:
#include "stdafx.h"
#include <iostream>
using namespace std;
class TEST
{
public:
struct node
{
int data;
};
node* f(void);
};
node* TEST::f(void)
{
node *ptr;
return (ptr);
}
int main(void)
{
cout << "blah... not needed" << endl;
return 0;
}
Here are the errors I receive: [I am using VC++ 2005 Express Edition]
Code:
1>.\class.cpp(16) : error C2143: syntax error : missing ';' before '*'
1>.\class.cpp(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\class.cpp(17) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\class.cpp(17) : error C2556: 'int *TEST::f(void)' : overloaded function differs only by return type from 'TEST::node *TEST::f(void)'
1> .\class.cpp(13) : see declaration of 'TEST::f'
1>.\class.cpp(17) : error C2371: 'TEST::f' : redefinition; different basic types
1> .\class.cpp(13) : see declaration of 'TEST::f'
I would appreciate any help with this... I have been stuck on it for about 2 days and I cannot proceed any further without fixing this issue, Thanks in advance for any help!